ShippingCategory.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. use Cpcommerce\ShippingNotifications\Model\ShippingCategory AS DelayedShippingCategory;
  8. use Cpcommerce\ShippingNotifications\Model\ResourceModel\ShippingCategory\Collection;
  9. use Magento\Framework\App\ResourceConnection;
  10. class ShippingCategory extends Template
  11. {
  12. protected $resource;
  13. public function __construct(
  14. Description $description,
  15. Repository $attribute,
  16. Context $context,
  17. array $data = [],
  18. DelayedShippingCategory $delayedShippingCategory,
  19. Collection $delayedCollection,
  20. ResourceConnection $resource
  21. ) {
  22. $this->description = $description;
  23. $this->attribute = $attribute;
  24. $this->delayedShippingCategory = $delayedShippingCategory;
  25. $this->delayedCollection = $delayedCollection;
  26. $this->resource = $resource;
  27. return parent::__construct($context, $data);
  28. }
  29. public function getAttributeData($attribute_code){
  30. return $this->attribute->get($attribute_code);
  31. }
  32. public function getShippingCategory(){
  33. $_product = $this->description->getProduct();
  34. $option_id = $_product->getShippingCategory();
  35. return $option_id;
  36. }
  37. public function getDelayedShippingCategories(){
  38. $this->delayedCollection->getSelect()->where("is_delayed = '1'");
  39. return $this->delayedCollection->load();
  40. }
  41. }