1
0
mirror of synced 2025-02-18 05:03:14 +03:00
magento-module/Model/Setting/Attribute.php
Alex Lushpai f4000c9874 v2.0
2017-05-31 15:24:46 +03:00

38 lines
901 B
PHP

<?php
namespace Retailcrm\Retailcrm\Model\Setting;
//use Psr\Log\LoggerInterface;
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 = array('text', 'multiselect', 'decimal');
$attributes = $this->_entityType->loadByCode('catalog_product')->getAttributeCollection();
$attributes->addFieldToFilter('frontend_input', $types);
$result = array();
foreach ($attributes as $attr) {
if ($attr->getFrontendLabel()) {
$result[] = array('value' => $attr->getAttributeId(), 'label' => $attr->getFrontendLabel(), 'title' => $attr->getAttributeCode());
}
}
return $result;
}
}