Richard Castera - Explorations in Software Development
Richard Castera - Explorations in Software Development
Browsing Category
Resources
Resources Scripts

Magento – Upgrade to the latest version using Magento Connect

August 4, 2009 9 Comments

Upgrading Magento to the latest version is a fairly simple task. Copy and Paste this key below VIA Magento Connect where it states “Paste extension key to install:”. This will upgrade Magento to the newest version.

XHTML
1
magento-core/Mage_All_Latest
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Magento – Get the Current Category

August 3, 2009 16 Comments

Need to get the current category loaded? No problem! Just use this useful little snippet below. It will return an object of the current category.

PHP
1
<?php $currentCategory = Mage::registry('current_category'); ?>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Magento – Add a product with custom options to the cart through URL Querystring

August 2, 2009 21 Comments

Magento is truly a powerful and flexible platform! I enjoy working with it more and more every day. I recently came across the need to add a product to the cart VIA the Querystring/URL. Guess what? Magento can do it and I’ll show you how!

Simple products are the easiest to add because there are fewer options that need to be passed. The basic structure is as follows.

XHTML
1
http://www.mydomain.com/checkout/cart/add?product=[id]&qty=[qty]

Where [id] is the Magento ID of the product and [qty] is the Quantity you wish to add.

To add a simple product with custom options simply add options[id]=[value] to the end. The basic structure is:

XHTML
1
http://www.mydomain.com/checkout/cart/add?product=[id]&qty=[qty]&options[id]=[value]

You can get the options id and value by viewing the source of the simple product page and it’s dropdowns.

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts Web Server

Using SSH and Unix commands

July 31, 2009 8 Comments

Having some basic knowledge of SSH and Unix commands is very useful. Developed in 1995, SSH (Secure Shell) was created as a secure alternative to Telnet. Telnet is a protocol allowing for command line access to a Unix, Linux or FreeBSD based remote computer. I’ve listed some basic commands to get you familiar with them.

The cd command is used to move to a specific directory.

Shell
1
2
Command: cd
Format: cd /directory/to/browse

The cp command will copy the file or folder from the source, to the destination.

Continue reading
Reading time: 2 min
Share:
Written by: rcastera
Resources Scripts

PHP – Convert Array to Object with stdClass

July 5, 2009 53 Comments

The PHP stdClass() is something that isn’t well documented but i will try to shed some light into the matter. stdClass is a default PHP object which has no predefined members. The name stdClass is used internally by Zend and is reserved. So that means that you cannot define a class named stdClass in your PHP code.

It can be used to manually instantiate generic objects which you can then set member variables for, this is useful for passing objects to other functions or methods which expect to take an object as an argument. An even more likely usage is casting an array to an object which takes each value in the array and adds it as a member variable with the name based on the key in the array.

Here’s an example below that converts an array to an object below. This method is called Type Casting.

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Web Server

Migrating Magento to another server

June 29, 2009 22 Comments

Migrating your Magento website to another server is relatively a simple task once you know how to do it of course. I have detailed the steps on how to do this below so you can use this post as a point of reference πŸ™‚

  1. From the admin, go to Configuration -> Web -> and change the (Unsecure and Secure) fields to {{base_url}}.
  2. From the admin, go to System -> Tools -> Backups and click on the backup button. This will create a backup of your database.
  3. Make a copy your Magento root.
  4. Move all data over to the new server.
  5. Restore the database on the new host.
  6. If you have a different username, password or database name. You’ll need to update that as well. You can find the file in (‘magento_root/app/etc/local.xml’) and make the required changes.
  7. Navigate to your Magento root, and delete all of the files and folders in, (i.e. /var/www/magento/var) except for the .htaccess file.

Hope this helps someone πŸ™‚

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

PHP – getting a list of currently loaded classes

June 25, 2009 1 Comment

In some cases you may need to investigate which classes are loaded in the current scope. You can do it pretty fine with the get_declared_classes() function. This function will return an array of currently available classes.

PHP
1
2
3
4
<?php
    include_once("class.myClass.php");
    print_r(get_declared_classes());
?>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Add Magento search plugin to Firefox Search bar

June 24, 2009 2 Comments

I’ve been working with Magento for some time now. I found myself searching for help countless times on the Magento website. I thought it would be useful to have a search feature built right into Firefox’s list of search engines to search the Magento site. So I went through Mozilla’s Developer Center and found instructions on the Open Search Syntax. So here you go, you can download it here. Hope you find it helpful!

I also have one for PHP which comes in handy as well. If your interested, you can grab it here.

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

Javascript – Passing Multiple Parameters through setTimeout

June 21, 2009 13 Comments

One of the problems that I’ve faced with Javascript is passing multiple parameters through the setTimeout function. I found this little snippet on the internet a few months ago and would like to share it with you. I don’t know who the original author is so I could not give him/her proper credit. Thanks!

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
<script>
var _st = window.setTimeout;
window.setTimeout = function (fRef, mDelay) {
    if (typeof fRef == "function") {
        var argu = Array.prototype.slice.call(arguments,2);
        var f = (function () {fRef.apply(null, argu);});
        return _st(f, mDelay);
    }
    return _st(fRef, mDelay);
}
</script>

Define your function to call with setTimeout:

JavaScript
1
2
3
4
5
<script>
function alertMe (message, name) {
    alert(message + name);
}
</script>

Now, just call the function.

JavaScript
1
2
3
var message = 'Hello, ';
var name = 'Richard';
setTimeout(alertMe, 2000, message, name);

Hope this helps someone! πŸ™‚

Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Resources Scripts

How to define your own JavaScript class

June 7, 2009 8 Comments

There are several ways to define a class in Javascript. I will be listing my favorite method below (JSON Method). It’s important to note that there are no real classes in JavaScript. Everything is considered an object. So below is our class definition:

JavaScript
1
2
3
4
5
6
7
8
9
10
<script>
var Person = {
    age: "25",
    sex: "Male",
    location: "New York",
    getASL: function () {
        return 'Age: ' + this.age + ', Sex: ' + this.sex + ', Location: ' + this.location;
    }
};
</script>

So you can start using the class like this:

JavaScript
1
2
3
4
<script>
Person.age = "29";
alert(Person.getASL());
<script>
Continue reading
Reading time: 1 min
Share:
Written by: rcastera
Page 4 of 9« First...«3456»...Last »

About me

Hello, my name is Richard Castera. I have more than 12 years of experience architecting, implementing, leading and launching large scale, high performance software products in a fast-paced agile environment.

Popular Posts

Magento – Display new products on the home page

May 20, 2009

How to Fix “Internet Explorer Cannot Open the Internet Site- Operation Aborted” Error

May 9, 2009

PHP – Convert Array to Object with stdClass

July 5, 2009

Categories

  • Home Automation
  • Resources
  • Scripts
  • SEO
  • Thoughts
  • Web Server

Tags

Apache Apple Bash CSS Drupal Free home automation htaccess Java Javascript Magento PHP raspberry pi SEO SQL thoughts Wordpress

Β© 2019 copyright Richard Castera // All rights reserved