I have a list of products on my homepage and I'm trying to display its associated color swatches but I'm having a hard time to do it. I have the configurable swatches in my product list and it's working fine.
I'm using RWD theme and Magento 1.9.1 CE.
<script type="text/javascript">
$j(document).on('product-media-loaded', function() {
ConfigurableMediaImages.init('<?php echo $this->getImageType(); ?>');
<?php foreach ($this->getProductImageFallbacks() as $imageFallback): ?>
ConfigurableMediaImages.setImageFallback(<?php echo $imageFallback['product']->getId(); ?>, $j.parseJSON('<?php echo $imageFallback['image_fallback']; ?>'));
<?php endforeach; ?>
$j(document).trigger('configurable-media-images-init', ConfigurableMediaImages);
});
</script>
in app/design/frontend//default/configurableswatches/catalog/media/js.phtml
is the cause of the problem.
But before that, I paste this in my local.xml
<cms_index_index translate="label">
<update handle="product_list"/>
<reference name="content">
<block type="configurableswatches/catalog_media_js_list" name="configurableswatches.media.js.list" />
</reference>
</cms_index_index>
Then I found out that the products don't populate its small images.
If you noticed, there's a for loop in the javascript above, but it doesn't work because getProductImageFallbacks() returns NULL.
This is what I put on my CMS content (Homepage)
{{block type="catalog/product_list" column_count="5" category_id="21" template="catalog/product/homepage-list.phtml"}}
In app/code/local/Mage/ConfigurableSwatches/Block/Catalog/Media/Js/Abstract.php line 69 in public function getProductImageFallbacks($keepFrame = null)
This $products = $this->getProducts();
gives me NULL. That's why it can't give the correct image fallback.
Best Answer
in your
catalog/product/homepage-list.phtml
find
img
tag for product image and update the codeafter rating summy or after image add this code
at the end of this file add
in layout folder open
configurableswatches.xml
file and add below codechange this code to like below
add below code to your
local.xml
file