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

39 lines
1.0 KiB
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-04-28 11:39:23 +03:00
private $entityType;
private $store;
2018-03-12 16:34:48 +03:00
public function __construct(
\Magento\Store\Model\Store $store,
\Magento\Eav\Model\Entity\Type $entityType
) {
2018-04-28 11:39:23 +03:00
$this->store = $store;
$this->entityType = $entityType;
2018-03-12 16:34:48 +03:00
}
public function toOptionArray()
{
$types = ['text', 'multiselect', 'decimal'];
2018-04-28 11:39:23 +03:00
$attributes = $this->entityType->loadByCode('catalog_product')->getAttributeCollection();
2018-03-12 16:34:48 +03:00
$attributes->addFieldToFilter('frontend_input', $types);
$result = [];
foreach ($attributes as $attr) {
if ($attr->getFrontendLabel()) {
2018-04-28 11:39:23 +03:00
$result[] = [
'value' => $attr->getAttributeId(),
'label' => $attr->getFrontendLabel(),
'title' => $attr->getAttributeCode()
];
2018-03-12 16:34:48 +03:00
}
}
return $result;
}
2017-05-31 15:24:46 +03:00
}