Home » Archive

Articles Archive for Year 2009

Magento, MySQL »

[31 Dec 2009 | 19 Comments]

Suppose, you have a product collection and you want to filter it by category. Suppose, you want to filter it by more than one category. You can use addCategoryFilter if you have only one category. But, what if you want to filter by more than one category?
Category ids are stored for product in a comma separated way. So, to filter product collection by more than one category, you have to use:
addAttributeToFilter(‘category_ids’,array(‘finset’=>$categoryIds));

Magento »

[31 Dec 2009 | 11 Comments]

Here is the code to create, read, and delete cookie in Magento.
Mage_Core_Model_Cookie class contains functions to set, get and delete cookie.

Wordpress »

[22 Dec 2009 | No Comment]

Generally the wordpress 404 page contains one or two sentence saying that the page is not found. But you can make it more user friendly. Instead of just writing plain text about page not found, we can display archive list and a search form. In this way, the visitor can search or browse your website instantly. This is a nice way to keep your visitors within your site.
I got this idea from wp-comfy theme.

Wordpress »

[22 Dec 2009 | No Comment]

Here is the procedure to create a custom archive page for your wordpress blog.
1) Create a file archives.php
2) Write the following code in it.

Magento »

[22 Dec 2009 | 2 Comments]

You can get current category from the following code:
You can get the parent category from the following code:

Magento »

[21 Dec 2009 | 17 Comments]

Here, I will be showing you the code to get sub categories of a particular category and the number of products (product count) present in the sub categories.
Like, I have a category named Furniture. The sub categories under Furniture are Living Room and Bedroom. Now, I 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 | 10 Comments]

If you have country code(e.g. NP, EN, NL) then you can get country name from the following code:
Get the collection of all the countries.

Magento »

[9 Dec 2009 | 19 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 | 8 Comments]

Scenario:
While editing product programatically from frontend. I was trying to change the status of the product with the following code:
Mage::getModel(‘catalog/product’)->load($product->getId())->setStatus(2)->save();

Google, Humor, Security »

[8 Dec 2009 | No Comment]

I’m human, Google !

I was googling something and google suddenly said sorry to me. It says my computer is sending automated queries. I was just googling “magento programmer developer nepal” by changing the word position at each time. I just googled this way for at most 5 times.
Google help says the following thing about this issue:

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 | 13 Comments]

$product->getCategoryIds() gives array of category ids 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 | No 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).