1
0
mirror of synced 2025-02-27 09:23:15 +03:00
magento-module/Model/Setting/Attribute.php
Akolzin Dmitry 3b6430cf7d Refactoring
2018-04-28 11:59:43 +03:00

39 lines
1.0 KiB
PHP

<?php
namespace Retailcrm\Retailcrm\Model\Setting;
class Attribute implements \Magento\Framework\Option\ArrayInterface
{
private $entityType;
private $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[] = [
'value' => $attr->getAttributeId(),
'label' => $attr->getFrontendLabel(),
'title' => $attr->getAttributeCode()
];
}
}
return $result;
}
}