Wednesday , December 19 2018
Home >> All tutorial >> How to use Magento`s category or product design programmatically?

How to use Magento`s category or product design programmatically?

I needed to load a block using AJAX request on catalog/category page. There is no problem to pass the category ID of the current category, but how can i load category’s design? Today we will find the way to solve this problem by this Magento tutorials.
During my research app/core/Mage/Catalog files I found a simple solution:

{code type=html}$category = Mage::getModel(‘catalog/category’)->load($categoryId);
if ($category->getId() && $category->getCustomDesign()) {
->applyDesign($category, Mage_Catalog_Model_Design::APPLY_FOR_CATEGORY);

The main purpose of model catalog/design is to apply category`s or product`s design to current design. If you want to apply product`s design, you must use Mage_Catalog_Model_Design::APPLY_FOR_PRODUCT as the second parameter and Mage_Catalog_Model_Product object as the first one. For example:

{code type=html}$product = Mage::getModel(‘catalog/product’)->load($productId);
if ($product->getId() && $product->getCustomDesign()) {
->applyDesign($product, Mage_Catalog_Model_Design::APPLY_FOR_PRODUCT);

Hope it help you all!

Here is the library of Magento Download for FREE (all versions)

Your Magento website needs a powerful Magento ERP for stock control.


magento erp

About Champ

Leave a Reply

Your email address will not be published. Required fields are marked *

Heap | Mobile and Web Analytics