Guest User

Untitled

a guest
Dec 18th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. <body>
  2. <referenceContainer name="product.info.social">
  3. <block class="MagentoFrameworkViewElementTemplate" name="product.info.custom" template="Lapisbard_Product::social.phtml" after="product.info.addtocart">
  4. </block>
  5. </referenceContainer>
  6. </body>
  7.  
  8. <p>Hey there !</p>
  9. <?php //$_product = $block->getProduct();
  10.  
  11. <?php
  12.  
  13. namespace TestCatalogBlockProductView;
  14.  
  15. use MagentoCatalogBlockProductAbstractProduct;
  16.  
  17. class Extra extends AbstractProduct
  18. {
  19.  
  20. }
  21.  
  22. <?xml version="1.0"?>
  23. <body>
  24. <referenceContainer name="product.info.social">
  25. <block class="TestCatalogBlockProductViewExtra"
  26. name="product.view.extra"
  27. template="Test_Catalog::product/view/extra.phtml"
  28. after="-">
  29. </block>
  30. </referenceContainer>
  31. </body>
  32.  
  33. <?php /* @var $block TestCatalogBlockProductViewExtra */?>
  34. <?php $_product = $block->getProduct() ?>
  35. <h3><?php echo 'My Product Name Is: ' . $_product->getName(); ?></h3>
  36.  
  37. public function getSomething()
  38. {
  39. return 'something'
  40. }
  41.  
  42. <?php echo $block->getSomething() ?>
  43.  
  44. /**
  45. * Class AbstractProduct
  46. * @api
  47. * @deprecated 101.1.0
  48. * @SuppressWarnings(PHPMD.NumberOfChildren)
  49. * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
  50. * @since 100.0.2
  51. */
  52. class AbstractProduct extends MagentoFrameworkViewElementTemplate
  53.  
  54. <?php
  55. namespace VendorModuleBlock;
  56.  
  57. use MagentoFrameworkViewElementTemplate;
  58. use MagentoFrameworkRegistry;
  59.  
  60. class ProductView extends Template
  61. {
  62. /**
  63. * @var Registry
  64. */
  65. protected $registry;
  66.  
  67. /**
  68. * @var MagentoCatalogModelProduct
  69. */
  70. protected $product;
  71.  
  72. /**
  73. * ProductView constructor.
  74. * @param TemplateContext $context
  75. * @param array $data
  76. * @param Registry $registry
  77. */
  78. public function __construct(
  79. TemplateContext $context,
  80. array $data = [],
  81. Registry $registry
  82. )
  83. {
  84. $this->registry = $registry;
  85. parent::__construct($context, $data);
  86. }
  87.  
  88. /**
  89. * @return MagentoCatalogModelProduct
  90. */
  91. public function getProduct()
  92. {
  93. if (is_null($this->product)) {
  94. $this->product = $this->registry->registry('product');
  95. }
  96.  
  97. return $this->product;
  98. }
  99. }
Add Comment
Please, Sign In to add comment