1

I'm using two modules to manage in stock/out of stock info and configurable product options (custom swatches). And there is also Ajax AddtoCart extension. There three work perfectly on product view page. However, on homepage there is Ajax popup for configurable products which renders streamlined product view with product options and add to cart button. I've managed stock extension by calling its js lib from AjaxCart layout xml and it work fine:

        <reference name="head" >
        ...
            <action method="addJs" ifconfig="ajaxcart/viewsetting/enableview"><script>stonepath/configurablestock/varien/configurable.js</script></action>
        ...
        </reference>

So then I've tried adding with head reference js and css for configurable swatches extension and they also load. The original xml of the module looks like this:

<layout>
<PRODUCT_TYPE_configurable>
    <reference name="head">
        <action method="addJs" ifconfig="easylife_switcher/settings/enabled">
            <js>easylife_switcher/event.simulate.js</js>
        </action>
        <action method="addJs" ifconfig="easylife_switcher/settings/enabled">
            <js>easylife_switcher/product.js</js>
        </action>
        <action method="addCss" ifconfig="easylife_switcher/settings/enabled">
            <css>css/easylife_switcher/styles.css</css>
        </action>
        <action method="removeItem" ifconfig="easylife_switcher/settings/enabled">
            <type>skin_js</type>
            <name>js/configurableswatches/product-media.js</name>
        </action>
        <action method="removeItem" ifconfig="easylife_switcher/settings/enabled">
            <type>skin_js</type>
            <name>js/configurableswatches/swatches-product.js</name>
        </action>
    </reference>
    <reference name="content">
        <block type="easylife_switcher/catalog_product_view_type_configurable_config" template="easylife_switcher/catalog/product/view/type/configurable/config.phtml" />
    </reference>
</PRODUCT_TYPE_configurable>

The last part bothers me:

  <reference name="content">
        <block type="easylife_switcher/catalog_product_view_type_configurable_config" template="easylife_switcher/catalog/product/view/type/configurable/config.phtml" />
    </reference>

I've tried calling this block from ajaxcart layout xml and from local.xml like this:

    <PRODUCT_TYPE_configurable>
    <reference name="content">
        <block type="easylife_switcher/catalog_product_view_type_configurable_config" template="easylife_switcher/catalog/product/view/type/configurable/config.phtml" />
    </reference>
</PRODUCT_TYPE_configurable>

Both times it's being completely ignored. Using debugger I can see handle is not loaded at all on the homepage. So how do I call it on the homepage? Or my logic is maybe wrong? Sorry if this may be a trivial question. I'm starting with Magento, have read a lot of answers here with similar problems but wasn't able to figure it out.

4

If you really want to add the Configurable Handle, here is a nice article about how doing so: http://inchoo.net/magento/custom-layout-update-handles/

But I think for what you want to achieve, it would be better and easier to just add the

<reference name="content">
        <block type="easylife_switcher/catalog_product_view_type_configurable_config" template="easylife_switcher/catalog/product/view/type/configurable/config.phtml" />
    </reference>

to the layout handle cms_index_index which is loaded on the homepage

But there is a good chance that the Block won't work on the homepage out of the Box. Blocks that are specifically designed for the product view page often rely on having the current_product in the registry

  • I've tried adding it to cms_index_index but then no product is loaded at all on the main page. I guess I'll go through the module code more to find out the culprit. Thanks. – psbz Feb 15 '16 at 9:16

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.