/** * Retrieve attribute store identifiers * * @param \Magento\Eav\Model\Attribute|int $attribute * @return array */ public function getStoreIds($attribute) { $adapter = $this->getConnection(); if ($attribute instanceof \Magento\Eav\Model\Attribute) { $attributeId = $attribute->getId(); } else { $attributeId = $attribute; } $select = $adapter->select()->from($this->getMainTable(), 'store_id')->where('attribute_id = ?', (int) $attributeId); return $adapter->fetchCol($select); }
/** * @return array */ public function getSwatchData() { if (false === $this->eavAttribute instanceof Attribute) { throw new \RuntimeException('Magento_Swatches: RenderLayered: Attribute has not been set.'); } $attributeOptions = []; foreach ($this->eavAttribute->getOptions() as $option) { if ($currentOption = $this->getFilterOption($this->filter->getItems(), $option)) { $attributeOptions[$option->getValue()] = $currentOption; } elseif ($this->isShowEmptyResults()) { $attributeOptions[$option->getValue()] = $this->getUnusedOption($option); } } $attributeOptionIds = array_keys($attributeOptions); $swatches = $this->swatchHelper->getSwatchesByOptionsId($attributeOptionIds); $data = ['attribute_id' => $this->eavAttribute->getId(), 'attribute_code' => $this->eavAttribute->getAttributeCode(), 'attribute_label' => $this->eavAttribute->getStoreLabel(), 'options' => $attributeOptions, 'swatches' => $swatches]; return $data; }
/** * Return scope values for attribute and website * * @param \Magento\Eav\Model\Attribute $object * @return array */ public function getScopeValues(\Magento\Eav\Model\Attribute $object) { $adapter = $this->_getReadAdapter(); $bind = array('attribute_id' => (int) $object->getId(), 'website_id' => (int) $object->getWebsite()->getId()); $select = $adapter->select()->from($this->_getEavWebsiteTable())->where('attribute_id = :attribute_id')->where('website_id = :website_id')->limit(1); $result = $adapter->fetchRow($select, $bind); if (!$result) { $result = array(); } return $result; }
/** * Return scope values for attribute and website * * @param \Magento\Eav\Model\Attribute $object * @return array */ public function getScopeValues(\Magento\Eav\Model\Attribute $object) { $connection = $this->getConnection(); $bind = ['attribute_id' => (int) $object->getId(), 'website_id' => (int) $object->getWebsite()->getId()]; $select = $connection->select()->from($this->_getEavWebsiteTable())->where('attribute_id = :attribute_id')->where('website_id = :website_id')->limit(1); $result = $connection->fetchRow($select, $bind); if (!$result) { $result = []; } return $result; }