Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Msrp.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Msrp\Model;
7 
9 use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory;
10 
11 class Msrp
12 {
16  protected $mapApplyToProductType = null;
17 
22 
26  public function __construct(
27  AttributeFactory $eavAttributeFactory
28  ) {
29  $this->eavAttributeFactory = $eavAttributeFactory;
30  }
31 
39  public function canApplyToProduct($product)
40  {
41  if ($this->mapApplyToProductType === null) {
43  $attribute = $this->eavAttributeFactory->create()->loadByCode(Product::ENTITY, 'msrp');
44  $this->mapApplyToProductType = $attribute->getApplyTo();
45  }
46  return in_array($product->getTypeId(), $this->mapApplyToProductType);
47  }
48 }
__construct(AttributeFactory $eavAttributeFactory)
Definition: Msrp.php:26