Magento: How to filter product collection using 2 or more category filters?

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 … Read more

Magento: Create, Read, Delete Cookie

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. /** * set cookie * name and value are mandatory; other parameters are optional and can be set as null * $period = cookie expire date */ Mage::getModel('core/cookie')->set($name, $value, $period, $path, $domain, $secure, … Read more

WordPress: Create custom archive page

This article shows how to create a custom archive page for your wordpress blog. In the following archive page, I have displayed yearly archive, monthly archive, category wise archive and all post archive. So, the newly created archive page will be a kind of all-in-one archive page. Here is the step-by-step guide: 1) Create a … Read more

Magento: Get current and parent category

This article shows how to get category information (category name, id, description, url, etc.) of the category page you are in. Along with the information of the parent category of the currently viewed category. Get current category // Get current category $currentCategory = Mage::registry('current_category'); Print current category array < pre> $currentCategory = Mage::registry('current_category'); echo " … Read more

Magento: Get sub categories and product count

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 … Read more

Magento: Adding attribute from MySql setup file

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. In the following example, the version of my module is 0.1.0.  I have added attribute for product. I have added a … Read more