I am working on reference block concept, in that I need to add new arguments and get the argument value on the .phmlt file.

in catalog_product_view.xml I've added the below line of code.

 <referenceBlock name="product.info.addtocart">
            <argument name="current_page" xsi:type="string">detail</argument>
            <argument name="all_page" xsi:type="string">all</argument>
         <!-- <action method="setData">
        </action> -->

       <block class="Learn\Test\Block\Sample" name="sample.otherproducts" as="sample.products" after="-" template="catalog/product/view/sample.phtml" />

Then in my sample.phtml file I am using the following lines for getting the value of the arguments


But nothing is get the value of the current_page arugment, what is the exact procedure to bind the value on reference block layout and get it into the .phtml file

Kindly share your thoughts and ideas, thanks in advance for your support

2 Answers 2


Add inside sample block:

<block class="Learn\Test\Block\Sample" name="sample.otherproducts" as="sample.products" after="-" template="catalog/product/view/sample.phtml">
        <argument name="current_page" xsi:type="string">detail</argument>
        <argument name="all_page" xsi:type="string">all</argument>

Now try following way:



Extend your block by Magento\Catalog\Block\Product\View class. For example:

class Learn\Test\Block\Sample extends Magento\Catalog\Block\Product\View
  • 1
    thanks for your update, but as per my requirement I want to add the argument on reference block section, is there has any way to do that?
    – senthil
    Commented Jan 23, 2019 at 14:46
  • Check updated answer
    – Sohel Rana
    Commented Jan 23, 2019 at 15:11
  • thanks for your support, but I am adding the same sample block also in catalog_category_view, catalogsearch_result_index, catalogsearch_advanced_result. so that the above procedure is not applicable in my case. if you have any other idea it'll much help me.
    – senthil
    Commented Jan 23, 2019 at 15:17
  • I tried as you mentioned way, it's working
    – senthil
    Commented Jan 24, 2019 at 5:36
  • Then how can I get the parameter values in block(sample.php) file instead of phtml file(sample.phtml)
    – senthil
    Commented Jan 24, 2019 at 5:58

The block sample.products is a child block for the product.info.addtocart parent block, so you can call the parent block in the child block (also in the .phtml file) using getParentBlock() method

In the phtml you can use the following syntax:


Your Answer

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

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