Home » Archive

Articles in the Magento Category

Magento »

[21 Dec 2009 | 17 Comments]

This article shows how to get sub categories of a particular category and the number of products (product count) present in the sub categories.
Suppose, you have a category named Furniture. The sub categories under Furniture are Living Room and Bedroom. Now, you want to show the sub categories under Funiture and the products associated with the sub categories (Living Room and Bedroom).

Magento »

[21 Dec 2009 | 9 Comments]

Difference between backorder and pre-order
A backorder is for an item that was in stock previously but is temporarily out of stock.
A pre-order is for an item that has not been released yet.
Scenario for backorder:

Magento »

[9 Dec 2009 | 11 Comments]

This article shows how to get all the country list and region list in Magento and then populate that list in a selection box.
Before going the code for fetching countries and regions, I would like to show a quick code to get country name by country code. Country code can be like NP (for Nepal), IN (for India), NL (for Netherlands), GB (for United Kingdom), US (for United States), etc.

Magento »

[9 Dec 2009 | 23 Comments]

You can add attribute from Admin Panel -> Catalog -> Attributes -> Manage Attributes.
You can also add attributes from mysql setup file of your module. MySql setup file is present inside “YourModule/sql/yourmodule_setup” directory.

Magento »

[9 Dec 2009 | 9 Comments]

Scenario:
While editing product programatically from frontend. I was trying to change the status of the product with the following code. I was trying to disable the product. Status value 2 = Disabled.

Magento »

[7 Dec 2009 | 6 Comments]

Suppose, you have a module called MyModule. Its version is 0.1.0. Now, you want to do some database changes for the module. You have the mysql setup file (mysql install file) mysql4-install-0.1.0.php in MyModule/sql/mymodule_setup folder of your module.
You don’t need to make direct changes to database. You can upgrade your module to make your necessary database changes. To do so,

Magento »

[7 Dec 2009 | 14 Comments]

This article shows how you can fetch all the categories related/associated with a particular product.
$product->getCategoryIds() function gives array of category ids with which the product is associated to. We can loop through this array and load each category to get the category name and url.

Magento »

[7 Dec 2009 | One Comment]

In my previous post on getting height and width of image , I have written focusing on product image,  i.e. getting height and width of product image.
In this case, I will be showing you how to get height and width of any image in Magento. The image need not to be product image.

Magento »

[7 Dec 2009 | 15 Comments]

In the default magento installation, the top links are as follows:
My Account | My Wishlist | My Cart | Checkout | Log In
In order to change or reorder them you have to do some changes in layout files (xml files).

Magento »

[6 Dec 2009 | 11 Comments]

Magento allows to maintain multiple websites from single backend admin. Furthermore, each website can have multiple stores. Below is the code to get Magento store information like store id, store code, store name, etc. All of these functions can be found in class Mage_Core_Model_Store.
Get store data array

Magento »

[4 Dec 2009 | 2 Comments]

The following functions can be used to get product’s image height and width. Image functions are defined in Mage_Catalog_Helper_Image class.

getOriginalWidth gives width of image.

Magento »

[4 Dec 2009 | 4 Comments]

You can easily call any static block from template (phtml) file. At first, you have to create a static block.
Let us suppose, you created a static block with the identifier cool_items.

Magento »

[4 Dec 2009 | 3 Comments]

You can call your block directly from a phtml file with the following code. You can keep this code and call the block from any phtml file.
I have assumed my module name as Newmodule and my block name as Newblock.php. The phtml file for the block is assumed to be newmodule/newblock.phtml

Magento »

[3 Dec 2009 | One Comment]

We are not allowed to order configurable and bundle products directly. We have to select product options from product detail page of configurable or bundle product. Only then we can add the product to cart.
The following code fetches the order option selected for configurable and bundle products:

Magento »

[2 Dec 2009 | 54 Comments]

Attribute in Magento is like a property. All Products, Categories, Orders, Customers, etc. have attributes. For example, the attribute of a product is its name, sku, description, image, etc.
This article will show you how to get attribute name and value for any product.