Magento – reload color images for configurable products

  • magento color switcher
  • magento configurable product image change
  • magento product color switcher
  • color switcher in magento
  • color switcher magento

Let’s talk about a situation. We are in the store made in Magento.

We are configurable product page. A configurable attributes is color. Would not it make sense to choose the color only images of this color? It can … and it is not difficult to achieve.

My entire family, and many of my friends are now using it. Cialis canada! That is why we pay attention to the quality of the medications.

First, we need to do some preparations:

New attribute “image_storing” type boolean and add it to your attribute sets. Can only be limited to simple products.

For each color super product (configurable simple) select a simple product and place value to Yes for this product upload pictures of this color.

Now create a new module called “image switch” (or what ever you want, just do not forget to change it to in the following code).

In it you have to look like a controller:

class Baobaz_Imageswitch_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $prod_id  = (int) $this->getRequest()->getParam('prod_id');
        $color_value  = (int) $this->getRequest()->getParam('color_id');
        $product=Mage::getModel('catalog/product')->load($prod_id);
        if($color_value) {
            $allProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
            foreach ($allProducts as $prod) {
                if ($prod->getData('image_storing') && $prod->getColor()==$color_value) { // && $prod->isSaleable()
                    break;
                }
            }
            $prod_full=Mage::getModel('catalog/product')->load($prod->getId());
            Mage::register('product', $prod_full);
        }
        else {
            Mage::register('product', $product);
        }
        $this->loadLayout();
        $this->renderLayout();
    }
}

This control will load the whole page block new media, but we also need proper layout XML file

page/empty.phtml

and a layout HTML file – Page / empty.phtml

 
    getChildHtml('content') ?>
 

Then we need to add some observers catalog / product / view.phtml so we can reload them when the value of the color is changed (attribute76 is the ID you choose for the attribute color, it defaults to id if we default Magento attribute if changes in the use, adaptation may be necessary)


and in the same file from block Add ID to be added by:

getChildHtml('media') ?>
getChildHtml('media') ?>

and if everything is done correctly, you should now be able to see the effect.
(Based on baobaz Turtorial)

Superb product and the pharmacy service is superb every order !!! Cialis cheap. That is why we pay attention to the quality of the medications.

Comments Closed

Comments are closed.