public function testGetProductAttributes() { $expectedResult = ['attribute_one', 'attribute_two', 'attribute_three']; $this->_catalogConfig->expects($this->once())->method('getProductAttributes')->willReturn(['attribute_one', 'attribute_two']); $this->_attributeConfig->expects($this->once())->method('getAttributeNames')->with('wishlist_item')->willReturn(['attribute_three']); $this->assertEquals($expectedResult, $this->model->getProductAttributes()); }
/** * Retrieve attribute codes using for flat * * @return array */ public function getAttributeCodes() { if ($this->_attributeCodes === null) { $adapter = $this->_resource->getConnection('read'); $this->_attributeCodes = []; foreach ($this->_flatAttributeGroups as $attributeGroupName) { $attributes = $this->_attributeConfig->getAttributeNames($attributeGroupName); $this->_systemAttributes = array_unique(array_merge($attributes, $this->_systemAttributes)); } $bind = ['backend_type' => \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::TYPE_STATIC, 'entity_type_id' => $this->getEntityTypeId()]; $select = $adapter->select()->from(['main_table' => $this->getTable('eav_attribute')])->join(['additional_table' => $this->getTable('catalog_eav_attribute')], 'additional_table.attribute_id = main_table.attribute_id')->where('main_table.entity_type_id = :entity_type_id'); $whereCondition = ['main_table.backend_type = :backend_type', $adapter->quoteInto('additional_table.is_used_for_promo_rules = ?', 1), $adapter->quoteInto('additional_table.used_in_product_listing = ?', 1), $adapter->quoteInto('additional_table.used_for_sort_by = ?', 1), $adapter->quoteInto('main_table.attribute_code IN(?)', $this->_systemAttributes)]; if ($this->isAddFilterableAttributes()) { $whereCondition[] = $adapter->quoteInto('additional_table.is_filterable > ?', 0); } $select->where(implode(' OR ', $whereCondition)); $attributesData = $adapter->fetchAll($select, $bind); $this->_eavConfig->importAttributesData($this->getEntityType(), $attributesData); foreach ($attributesData as $data) { $this->_attributeCodes[$data['attribute_id']] = $data['attribute_code']; } unset($attributesData); } return $this->_attributeCodes; }
/** * Enter description here... * * @param boolean $sorted * @return Collection */ protected function _getDefaultCollection($sorted = false) { $this->_joinUrlRewriteIntoCollection = true; $collection = $this->_collectionFactory->create(); $attributes = $this->_attributeConfig->getAttributeNames('catalog_category'); $collection->addAttributeToSelect($attributes); if ($sorted) { if (is_string($sorted)) { // $sorted is supposed to be attribute name $collection->addAttributeToSort($sorted); } else { $collection->addAttributeToSort('name'); } } return $collection; }
/** * Get product attributes that need in wishlist * * @return array */ public function getProductAttributes() { $catalogAttributes = $this->_catalogConfig->getProductAttributes(); $wishlistAttributes = $this->_attributeConfig->getAttributeNames('wishlist_item'); return array_merge($catalogAttributes, $wishlistAttributes); }
/** * @param \Magento\Catalog\Model\Attribute\Config $attributeConfig */ public function __construct(Attribute\Config $attributeConfig) { $this->unassignableAttributes = $attributeConfig->getAttributeNames('unassignable'); }
/** * Retrieve list of attributes that allowed for autogeneration * * @return array */ public function getAttributesAllowedForAutogeneration() { return $this->_attributeConfig->getAttributeNames('used_in_autogeneration'); }
public function testGetAttributeNames() { $expectedResult = ['fixture_attribute_one', 'fixture_attribute_two']; $this->_dataStorage->expects($this->once())->method('get')->with('some_group')->will($this->returnValue($expectedResult)); $this->assertSame($expectedResult, $this->_model->getAttributeNames('some_group')); }
/** * @return array */ public function getProductAttributes() { return $this->_attributeConfig->getAttributeNames('quote_item'); }