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?
2 Answers 2
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
-
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– onyotzki2015年04月15日 05:05:48 +00:00Commented Apr 15, 2015 at 5:05
At a glance it looks like your reference name is wrong: change product.info to product.info.addtocart