Create new product attribute with options

Hello, Good to see you again. Today i am going to discribe how to create new attribute for product with options and assign to all products with default value. Here i have describe the code to create new attribute and assigned to products.   $installer = Mage::getResourceModel('catalog/setup','default_setup'); $installer->startSetup(); Get setup resource model and start installer set-up. $entity = 'catalog_product'; $newAttribute = 'some_new_attribute'; Define entity type and new attribute code. $entityTypeId = $installer->getEntityTypeId($entity); Get entity type id from en...
More

How to download multiple files with ZIP in Magento.

Hello, Today i'll explain you, how can we download multiple files with ZIP in Magento. To download any file in Magento usually we used simple flow of Magento with controller method, but we get confuse while we need to download multiple files at same time. To download multiple files at same in download request we should use ZIP method, which will include all the files which allows to download. Here is the code and code explanation to use ZIP method in Magento to download multiple files. if(!extension_loaded('zip')){ Mage::log("Zip Extension does not loaded"); return false; } Check whet...
More

How to get child product of composite products?

In Magento there are mainly two type of products that are simple type and composite type product. These two type of products are further divided into six type. Simple Type Simple product Downloadable product Virtual product. Composite Type Configurable product. Bundle product. Grouped product. Some times we need to get further detail for child product of Composite/Parent product which are used in parent product. To get detail of child products we can use type-instance of parent product as shown below. 1) Configurable product. To get detail info of configurable product type w...
More

How to use Cookie with Magento?

Some time developer gets stuck with how to pass variable value from PHP to JavaScript (server side to client side). We can found a solution with cookie. Because cookie is the feature which is available at both side (PHP & JavaScript / Server side & Client side). In Magento it has in-built JS library for cookie that his js\mage\cookies.js and for php side it has cookie model (core/cookie). So in magento we do not need to write core function for cookie.   How to use cookie in JS? Set cookie value. Mage.Cookies.set(‘somename’,’somevalue’); Get Cookie value Mage.Cookies.get(‘so...
More

How to run Magento indexer using command prompt?

Magento provides indexer process by browser base as well command prompt. To run indexer process from browser base go to admin side system configuration menu "System -> Configuration -> Index Management". To run indexer process from command prompt follow below steps. -> Open command prompt /** Go to PHP exe directory */ -> Type & press enter : cd your_drive:\wamp\bin\php\php5.2.5 /** Now use "PHP" word and indexer.php file path of your Magento set-up followed by indexing option */ --> To Reindex all indexes php your_drive/magento/setup/indexer.php --reindexall...
More

How to use magento core query for read and write?

Most of the Magento developer preferred to use module model object or model resource object for Magento query, but even though some time need to use core query. To use core query method use below code. /** Core resource object */      $resource = Mage::getSingleton('core/resource'); /** Read adapter connection */     $read= $resource->getConnection('core_read'); /** table name to fetch records */      $clientsTable = $resource->getTableName('clients'); /** Select query with where clause and order by */   &nb...
More

How to resize image in magento?

To resize image in magento use below code and pass image url as parameter in Varien_Image object. /** Varien Image object for image url */     $imageObj = new Varien_Image($imageUrl); /** Set constrain */     $imageObj->constrainOnly(true); /** Keep Image Aspect ratio */     $imageObj->keepAspectRatio(false); /** Keep Image frame */     $imageObj->keepFrame(false); /** Keep Image Transparency */     $imageObj->keepTransparency(true); /** Set image background Color */ &nbs...
More

Create Layered Navigation for custom product collection

Here are the changes what you need do. 1) Created one custom module for custom page. My custom page URL was http://{magento_root}/onsale. 2) Set below Layout XML file for my custom page layout ('onsale' is my custom attribute). <onsale_index_index translate="label"> <reference name="left"> <block type="onsale/layer_view" name="customlayer" after="currency" template="catalog/layer/view.phtml"/> </reference> <reference name="content"> <block type="core/template" name="category.products" template="onsale/category/view.phtml"> <block type="onsale/pro...
More