How to call custom block twice with different attributes

by Ella   Last Updated May 15, 2018 20:09 PM

I'm trying to call a custom block twice in two separate table cells on a magento cms page, but so far the custom attribute is only set the first time, so that the template in both of these cells are using id 10, rather than 10 and then 12.

<td>{{block class="Namespace\Catalog\Block\NewProduct" product_id="10" template="Magento_Catalog::product/view/price_buy.phtml"}}</td>

<td>{{block class="Namespace\Catalog\Block\NewProduct" product_id="12" template="Magento_Catalog::product/view/price_buy.phtml"}}</td>

I also tried to loop through an array inside the template, and only call the block once, but so far while some of the data in the template is correct, it still seems to revert to the first id in both cells for some data.

{{block class="Namespace\Catalog\Block\NewProduct" product_id="10|12" template="Magento_Catalog::product/view/price_buy.phtml"}}

Is there a way to clear the block so that it can be used twice?

Tags : magento2

Related Questions

Cart Price Rules having issues

Updated October 01, 2018 18:09 PM

Can Magento2 Enterprise see admin revenue

Updated November 21, 2018 13:09 PM

Magento 2.2 Not Loading theme and blocks

Updated January 11, 2018 02:09 AM