Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AttributesList.php
Go to the documentation of this file.
1 <?php
7 
9 {
13  protected $collectionFactory;
14 
18  public function __construct(
19  \Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $collectionFactory
20  ) {
21  $this->collectionFactory = $collectionFactory;
22  }
23 
30  public function getAttributes($ids)
31  {
32  $collection = $this->collectionFactory->create();
33  $collection->addFieldToFilter('main_table.attribute_id', $ids);
34  $attributes = [];
35  foreach ($collection->getItems() as $attribute) {
36  $attributes[] = [
37  'id' => $attribute->getId(),
38  'label' => $attribute->getFrontendLabel(),
39  'code' => $attribute->getAttributeCode(),
40  'options' => $attribute->getSource()->getAllOptions(false)
41  ];
42  }
43  return $attributes;
44  }
45 }
__construct(\Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory $collectionFactory)
$attributes
Definition: matrix.phtml:13