1
0
mirror of synced 2024-12-02 01:36:02 +03:00
magento-module/Model/Setting/Attribute.php

35 lines
964 B
PHP
Raw Normal View History

2017-05-31 15:24:46 +03:00
<?php
namespace Retailcrm\Retailcrm\Model\Setting;
class Attribute implements \Magento\Framework\Option\ArrayInterface
{
2018-03-12 16:34:48 +03:00
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;
}
2017-05-31 15:24:46 +03:00
}