1
0
mirror of synced 2024-11-28 16:06:06 +03:00
magento-module/Model/Setting/Attribute.php
2018-03-12 16:34:48 +03:00

35 lines
964 B
PHP

<?php
namespace Retailcrm\Retailcrm\Model\Setting;
class Attribute implements \Magento\Framework\Option\ArrayInterface
{
protected $_entityType;
protected $_store;
public function __construct(
\Magento\Store\Model\Store $store,
\Magento\Eav\Model\Entity\Type $entityType
) {
$this->_store = $store;
$this->_entityType = $entityType;
}
public function toOptionArray()
{
$types = ['text', 'multiselect', 'decimal'];
$attributes = $this->_entityType->loadByCode('catalog_product')->getAttributeCollection();
$attributes->addFieldToFilter('frontend_input', $types);
$result = [];
foreach ($attributes as $attr) {
if ($attr->getFrontendLabel()) {
$result[] = array('value' => $attr->getAttributeId(), 'label' => $attr->getFrontendLabel(), 'title' => $attr->getAttributeCode());
}
}
return $result;
}
}