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
|
|
|
}
|