Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AAllenSandboxBlockProductView;
  4.  
  5.  
  6. use MagentoCatalogApiProductRepositoryInterface;
  7. use MagentoFrameworkPricingPriceCurrencyInterface;
  8.  
  9. class Attributes extends MagentoCatalogBlockProductViewAttributes
  10. {
  11. protected $_productRepo;
  12.  
  13. public function __construct(
  14. MagentoFrameworkViewElementTemplateContext $context,
  15. MagentoFrameworkRegistry $registry,
  16. PriceCurrencyInterface $priceCurrency,
  17. ProductRepositoryInterface $productRepository,
  18. array $data = []
  19. )
  20. {
  21. $this->_productRepo = $productRepository;
  22.  
  23. parent::__construct($context, $registry, $priceCurrency, $data);
  24. }
  25.  
  26. public function setProductById($productId)
  27. {
  28. $this->_product = $this->_productRepo->getById($productId);
  29.  
  30. return $this;
  31. }
  32. }
  33.  
  34. <?php echo $block->getChildBlock('attribute.set')->setProductById($_product->getId())->toHtml() ?>
  35.  
  36. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  37. <body>
  38. <referenceBlock name="category.products.list">
  39. <action method="setTemplate">
  40. <argument name="template" xsi:type="string">Your_Module::product/list.phtml</argument>
  41. </action>
  42. <block class="YourModuleBlockProductViewAttributes" name="attribute.set" template="Magento_Catalog::product/view/attributes.phtml"/>
  43. </referenceBlock>
  44. </body>
  45. </page>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement