ShippingCategory.php 989 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Cpcommerce\ShippingNotifications\Block;
  3. use Magento\Catalog\Block\Product\View\Description;
  4. use Magento\Catalog\Model\Product\Attribute\Repository;
  5. use Magento\Framework\View\Element\Template;
  6. use Magento\Framework\View\Element\Template\Context;
  7. class ShippingCategory extends Template
  8. {
  9. public function __construct(
  10. Description $description,
  11. Repository $attribute,
  12. Context $context,
  13. array $data = []
  14. ) {
  15. $this->description = $description;
  16. $this->attribute = $attribute;
  17. return parent::__construct($context, $data);
  18. }
  19. public function getAttributeData($attribute_code){
  20. return $this->attribute->get($attribute_code);
  21. }
  22. public function getShippingCategory(){
  23. $_product = $this->description->getProduct();
  24. $shipping_category = $_product->getResource()->getAttribute('shipping_category')->getFrontend()->getValue($_product);
  25. return $shipping_category;
  26. }
  27. }