| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace Cpcommerce\ShippingNotifications\Block;
- use Magento\Catalog\Block\Product\View\Description;
- use Magento\Catalog\Model\Product\Attribute\Repository;
- use Magento\Framework\View\Element\Template;
- use Magento\Framework\View\Element\Template\Context;
- class ShippingCategory extends Template
- {
- public function __construct(
- Description $description,
- Repository $attribute,
- Context $context,
- array $data = []
- ) {
- $this->description = $description;
- $this->attribute = $attribute;
- return parent::__construct($context, $data);
- }
- public function getAttributeData($attribute_code){
- return $this->attribute->get($attribute_code);
- }
- public function getShippingCategory(){
- $_product = $this->description->getProduct();
- $shipping_category = $_product->getResource()->getAttribute('shipping_category')->getFrontend()->getValue($_product);
- return $shipping_category;
- }
- }
|