Magento: Get order option of configurable and bundle product in cart

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: // For configurable product Mage::getModel('catalog/product_type_configurable')->getOrderOptions($this->getProduct()); // For … Read more

Magento: How to get attribute name and value?

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. Get attribute’s name, value, type, and other parameters The attribute code … Read more

Magento: Redirect functions

The redirect functions are present in Mage_Core_Controller_Varien_Action class. /* Redirect to certain url  */ _redirectUrl($url) /* Redirect to certain path */ _redirect($path, $arguments=array()) /* Redirect to success page */ _redirectSuccess($defaultUrl) /* Redirect to error page */ _redirectError($defaultUrl) /* Set referer url for redirect in response */ _redirectReferer($defaultUrl=null) /*  Identify referer url via all accepted methods … Read more

Magento: How to delete System Attribute?

Suppose, you want to delete an attribute. But there is no delete option while you edit the attribute. This means that the attribute is system attribute. System attributes cannot be deleted. Only user defined attributes can be deleted. To delete the attribute, you have to make it user defined. – Go to phpmyadmin – Go … Read more

Magento: Describing Flat Catalog

Difference between EAV and Flat Catalog In EAV database model, data are stored in different smaller tables rather than storing in a single table. Like, product name is stored in catalog_product_entity_varchar table product id is stored in catalog_product_entity_int table product price is stored in catalog_product_entity_decimal table EAV database model is used by Magento for easy … Read more

Magento: Writing Custom Log Message

To be able to write your custom log message, you have to enable logging from Magento Admin. To enable logging, go to Magento Admin Panel -> System -> Configuration -> Developer -> Log Settings -> Enabled = Yes Then in your code, you can write the following: Mage::log("Your Log Message"); You can check it at … Read more

Javascript: Show/Hide HTML elements

Here, I will be demonstrating on showing or hiding a div when a link is clicked. I have done this with Javascript and CSS. I have called showHideDiv() Js function when the link is clicked. The display of the div where content is present, is visible or hidden on each click. For this, CSS styling … Read more

Magento: Load store specific product

Different stores can be set in Magento. A product can be made visible in selected stores. /** * get store id */ $storeId = Mage::app()->getStore()->getId(); /** * call the Magento catalog/product model * set the current store ID * load the product */ $product = Mage::getModel('catalog/product') ->setStoreId($storeId) ->load($key); Hope it helps. Thanks.

Magento: Get parent id of simple product associated to configurable product

Scenario: A simple product is associated with a configurable product. You have the id of the simple product. Now, you need the id of the configurable product with which the simple product is associated. Get parent product id, i.e. get id of configurable product from a simple product. Note: This method is deprecated after 1.4.2.0 … Read more