1

I'm trying to get configurable swatches to work in my own custom theme, and have followed these instructions: How to use Magento 1.9.1.0 Configurable Swatches in Default package theme (or a custom theme)?

This works for the product page, but I don't get the swatches showing up in the list view.

The rwd catalog xml file has this entry:

<catalog_category_layered translate="label">
<reference name="content">
    <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
        <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
            <block type="core/text_list" name="product_list.name.after" as="name.after" />
        </block
    </block
</reference>
</catalog_category_layered>

if I add in:

<block type="core/text_list" name="product_list.name.after" as="name.after" />

To my base theme catalog.xml file in the same spot it works, so what do I put in my theme's xml file to get this to work the same? How do I target the block called product_list to add that core/text_list block into it?

0

To make it work you need to add

<block type="core/text_list" name="product_list.name.after" as="name.after" />
<block type="core/text_list" name="product_list.after" as="after" />

after

<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">

in catalog.xml under catalog_category_layered section and copy

app\design\frontend\rwd\default\template\catalog\product\list.phtml

to your theme

0
<block type="core/text_list" name="product_list.name.after" as="name.after" />
<block type="core/text_list" name="product_list.after" as="after" />

after

 <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">

in catalog_category_layered and catalog_category_default also you need to change in list.phtml where ever you want to display swatch add this code

    <?php
    // Provides extra blocks on which to hang some features for products in the list
    // Features providing UI elements targeting this block will display directly below the product name
    if ($this->getChild('name.after')) {
        $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
        foreach ($_nameAfterChildren as $_nameAfterChildName) {
            $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);
            $_nameAfterChild->setProduct($_product);
            echo $_nameAfterChild->toHtml();
        }
    }
?>

and add this below code in end of list.phtml

    <?php
// Provides a block where additional page components may be attached, primarily good for in-page JavaScript
if ($this->getChild('after')) {
    $_afterChildren = $this->getChild('after')->getSortedChildren();
    foreach ($_afterChildren as $_afterChildName) {
        $_afterChild = $this->getChild('after')->getChild($_afterChildName);
        //set product collection on after blocks
        $_afterChild->setProductCollection($_productCollection);
        echo $_afterChild->toHtml();
    }
}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.