本文整理匯總了PHP中Magento\CatalogImportExport\Model\Import\Product::getAttributeOptions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Product::getAttributeOptions方法的具體用法?PHP Product::getAttributeOptions怎麽用?PHP Product::getAttributeOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\CatalogImportExport\Model\Import\Product
的用法示例。
在下文中一共展示了Product::getAttributeOptions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: attachAttributesById
/**
* Attach Attributes By Id
*
* @param string $attributeSetName
* @param array $attributeIds
* @return void
*/
protected function attachAttributesById($attributeSetName, $attributeIds)
{
foreach ($this->_prodAttrColFac->create()->addFieldToFilter('main_table.attribute_id', ['in' => $attributeIds]) as $attribute) {
$attributeCode = $attribute->getAttributeCode();
$attributeId = $attribute->getId();
if ($attribute->getIsVisible() || in_array($attributeCode, $this->_forcedAttributesCodes)) {
self::$commonAttributesCache[$attributeId] = ['id' => $attributeId, 'code' => $attributeCode, 'is_global' => $attribute->getIsGlobal(), 'is_required' => $attribute->getIsRequired(), 'is_unique' => $attribute->getIsUnique(), 'frontend_label' => $attribute->getFrontendLabel(), 'is_static' => $attribute->isStatic(), 'apply_to' => $attribute->getApplyTo(), 'type' => \Magento\ImportExport\Model\Import::getAttributeType($attribute), 'default_value' => strlen($attribute->getDefaultValue()) ? $attribute->getDefaultValue() : null, 'options' => $this->_entityModel->getAttributeOptions($attribute, $this->_indexValueAttributes)];
$this->_addAttributeParams($attributeSetName, self::$commonAttributesCache[$attributeId], $attribute);
}
}
}
示例2: _initAttributes
/**
* Initialize attributes parameters for all attributes' sets.
*
* @return $this
*/
protected function _initAttributes()
{
// temporary storage for attributes' parameters to avoid double querying inside the loop
$attributesCache = [];
foreach ($this->_attrSetColFac->create()->setEntityTypeFilter($this->_entityModel->getEntityTypeId()) as $attributeSet) {
foreach ($this->_prodAttrColFac->create()->setAttributeSetFilter($attributeSet->getId()) as $attribute) {
$attributeCode = $attribute->getAttributeCode();
$attributeId = $attribute->getId();
if ($attribute->getIsVisible() || in_array($attributeCode, $this->_forcedAttributesCodes)) {
if (!isset($attributesCache[$attributeId])) {
$attributesCache[$attributeId] = ['id' => $attributeId, 'code' => $attributeCode, 'is_global' => $attribute->getIsGlobal(), 'is_required' => $attribute->getIsRequired(), 'is_unique' => $attribute->getIsUnique(), 'frontend_label' => $attribute->getFrontendLabel(), 'is_static' => $attribute->isStatic(), 'apply_to' => $attribute->getApplyTo(), 'type' => \Magento\ImportExport\Model\Import::getAttributeType($attribute), 'default_value' => strlen($attribute->getDefaultValue()) ? $attribute->getDefaultValue() : null, 'options' => $this->_entityModel->getAttributeOptions($attribute, $this->_indexValueAttributes)];
}
$this->_addAttributeParams($attributeSet->getAttributeSetName(), $attributesCache[$attributeId], $attribute);
}
}
}
return $this;
}