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?

asked Apr 15, 2015 at 3:50

2 Answers 2

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

7ochem
7,61516 gold badges54 silver badges82 bronze badges
answered Apr 15, 2015 at 4:14
1
  • 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"; ?> Commented Apr 15, 2015 at 5:05
0

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

answered Apr 15, 2015 at 3:52
1
  • Doesn't work :( Commented Apr 15, 2015 at 3:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.