4

The word "In Stock" was added inside catalog.xml:

<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml">
    <action method="setData">
        <name>instock_text</name>
        <value>In Stock</value>
    </action>
</block>

I want to rename it via Custom Layout Update XML so it would appear a different text for some products.

<reference name="product.info">
    <block type="catalog/product_view">
        <action method="setData">
            <name>in_stock_text</name>
            <value>This product is in stock.</value>
        </action>
    </block>
</reference>

The custom layout xml seems not working. Did I miss something on update xml?

3

You remove block <block type="catalog/product_view"> from custom layout. As per magento system any function value set and child blocks assign of a block class can be managed using <reference> tag

<reference name="product.info.addtocart">
    <action method="setData">
        <name>in_stock_text</name>
        <value>This product is in stock.</value>
    </action>
</reference>

You can study about layout

tutsplus

smashingmagazine

Magentogarden

| improve this answer | |
  • Thanks @amit-bera :) However, it seems not to be working as well. I'm suspecting my theme doesn't allow to get new variable values from other areas. My temporary workaround for this one is to provide a condition if the variable is set or not. Something like this: <?php echo $this->getInStockText() ? $this->getInStockText() : "In Stock"; ?> – onyotzki Apr 15 '15 at 5:05
0

At a glance it looks like your reference name is wrong: change product.info to product.info.addtocart

| improve this answer | |
  • Doesn't work :( – onyotzki Apr 15 '15 at 3:58

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.