Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CustomAttributeFilterCheck.php
Go to the documentation of this file.
1 <?php
7 
9 use Magento\Eav\Model\Config as EavConfig;
11 
19 {
23  private $eavConfig;
24 
28  public function __construct(
29  EavConfig $eavConfig
30  ) {
31  $this->eavConfig = $eavConfig;
32  }
33 
41  public function isCustom(FilterInterface $filter)
42  {
43  $attribute = $this->getAttributeByCode($filter->getField());
44 
45  return $attribute
46  && $filter->getType() === FilterInterface::TYPE_TERM
47  && in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true);
48  }
49 
57  private function getAttributeByCode($field)
58  {
59  return $this->eavConfig->getAttribute(Product::ENTITY, $field);
60  }
61 }