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

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.

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:

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

Using SSH and Unix commands

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.

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

mkdir creates a directory.

The rmdir command deletes a directory.

The rm command deletes a file.

The mv command will rename or move a file stated in the first portion to the name or location stated in the second portion.

This command will tar zip the files in the directory specified in the second portion into a tar file specified in the first portion.

The tar -xvf will extract all files from the tarball specified into the directory you are currently in.

This will create a zip file, with the name specified in the first portion from the file or directory listed in the second portion.

This command will unzip or un pack the named zip file, into the directory you’re currently in.

The Ls command lists files, and folders within the directory you specify

This will add a forward slash to the directory names within the directory you specify

This will show “hidden” files in the directory you specify

This command shows detailed info about each file in the directory you specify.

Also, a lightweight, freeware application which supports SSH commands for windows is PuTTY if you aren’t on a MAC.

PHP – Convert Array to Object with stdClass

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.

Here’s an example below that converts a multi-dimensional array to an object. This is accomplished through recursion.


Migrating Magento to another server

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 🙂

PHP – getting a list of currently loaded classes

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.


Add Magento search plugin to Firefox Search bar

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.

Javascript – Passing Multiple Parameters through setTimeout

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!

Define your function to call with setTimeout:

Now, just call the function.

Hope this helps someone! 🙂

How to define your own JavaScript class

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:

So you can start using the class like this:


Magento Beginners Guide – A great book for any Magento Store Owner

Recently I obtained a copy of Magento Beginner’s Guide by William Rice from Packt Publishing. This book is great, I would recommend it to any new or existing Magento store owner. It servers as an excellent reference guide for experienced users and a great beginners guide for new store owners.

Magento is the world’s most evolved e-commerce solution and runs on the Apache/MySQL/PHP platform. From one installation, users can control multiple storefronts, all sharing customer and product information. Magento’s templates and themes enable users to customize the look and feel of their store, even optimizing it for mobile phones. Extensions enable them to connect Magento to a large number of payment gateways and shipping services.

Who this book is written for:
This book is for anyone who wants to create an online store using Magento. If you are a non-technical person and are discouraged by the complexity of this powerful e-commerce application, this book is ideal for you.

What you will learn from this book:

  • Install and configure Magento and add products to your online catalog
  • Create categories and attributes to build your catalog of products
  • Enhance your products with descriptions, images, and inventory information
  • Create product categories to help your customers navigate your online store
  • Automatically apply sales tax rules to different shipping addresses and different types of products
  • Present and sell products in groups and sets
  • Display products related to the one that is being viewed by a customer
  • Offer your customer choices for a product’s size, color, or other attribute and give discounts based on quantities
  • Accept payments using Paypal, credit cards, and checks/money orders and offer a variety of shipping options
  • Create your own, customized shipping rates and connect to shippers such as UPS, FedEx, and USPS

Thanks to Jude at Packt Publishing for inviting me to write this review.

I also cannot underestimate these useful resources:

.htaccess – Limit website access by IP

I’ve been asked many times how to limit website access by allowable IP’s. This is fairly simple to accomplish with .htaccess and very useful for blocking web vagrants to allowing you to make updates to a website while redirecting all other IP’s to a maintenance page. Simply follow the steps below:

  1. Create a file and name it .htaccess.
  2. Add The following to the file:

  3. Replace with you IP address. (If you don’t know it, you can get it here: WhatsMyIP)
  4. Once the file is created, put it in the root directory. That’s it!
Page 6 of 11« First...234567891011