Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AAllenSandboxBlockProductView;
- use MagentoCatalogApiProductRepositoryInterface;
- use MagentoFrameworkPricingPriceCurrencyInterface;
- class Attributes extends MagentoCatalogBlockProductViewAttributes
- {
- protected $_productRepo;
- public function __construct(
- MagentoFrameworkViewElementTemplateContext $context,
- MagentoFrameworkRegistry $registry,
- PriceCurrencyInterface $priceCurrency,
- ProductRepositoryInterface $productRepository,
- array $data = []
- )
- {
- $this->_productRepo = $productRepository;
- parent::__construct($context, $registry, $priceCurrency, $data);
- }
- public function setProductById($productId)
- {
- $this->_product = $this->_productRepo->getById($productId);
- return $this;
- }
- }
- <?php echo $block->getChildBlock('attribute.set')->setProductById($_product->getId())->toHtml() ?>
- <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
- <body>
- <referenceBlock name="category.products.list">
- <action method="setTemplate">
- <argument name="template" xsi:type="string">Your_Module::product/list.phtml</argument>
- </action>
- <block class="YourModuleBlockProductViewAttributes" name="attribute.set" template="Magento_Catalog::product/view/attributes.phtml"/>
- </referenceBlock>
- </body>
- </page>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement