Hi guys,
i have two files which is in same module i.e module_sales.
path :1
vendor/magento/module-sales/view/frontend/templates/order/items/renderer/default.phtml
code :
$block \Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer */
$_item = $block->getItem();
Note : i want to access above block and variable in below file i.e items.phtml .
path:2
vendor/magento/module-sales/view/frontend/templates/email/items.phtml
how can i access can anyone guide me ?
while declaring in the layout file call the same block class but give different names with different templates.
Example:
<referenceContainer name="content"> <block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" name="items_name" template="order/items/renderer/default.phtml" />
<block after="content" class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" name="another_name" template="email/items.phtml" />
</referenceContainer>
Thanks!!
i do used the below mentioned way . can you tell me is this correct or not ?
layout file for default.phtml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="sales.order.items.renderers">
<block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" name="items2_name" template="email/items.phtml" />
<block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" name="sales.order.items.renderers.default" as="default" template="Magento_Sales:rder/items/renderer/default.phtml"/>
</referenceBlock>
</body>
</page>
layout file for items.phtml
<block class="Magento\Sales\Block\Order\Item\Renderer\DefaultRenderer" name="items2_name" template="email/items.phtml" />
<block class="Magento\Sales\Block\Order\Email\Items" name="items" template="Magento_Sales::email/items.phtml"
is this throwing any error?
Check reference from below blog might be helpful for you,
https://www.rakeshjesadiya.com/how-to-override-magento-2-order-items-renderer-default-phtml/