我们想通过 Magento-API 在另一个系统中导出/导入可配置产品。对我们来说重要的是可配置产品的价值,例如具有 3 种颜色(红色、绿色和蓝色)的 T 恤。
我们收到具有以下功能的可配置属性:
public function options($productId, $store = null, $identifierType = null)
{
$product = $this->_getProduct($productId, $store, $identifierType);
if (!$product->getId()) {
$this->_fault('not_exists');
}
$configurableAttributeCollection = $product->getTypeInstance()->getConfigurableAttributes();
$result = array();
foreach($configurableAttributeCollection as $attribute){
$result[$attribute->getProductAttribute()->getAttributeCode()] = $attribute->getProductAttribute()->getFrontend()->getLabel();
//Attr-Code: $attribute->getProductAttribute()->getAttributeCode()
//Attr-Label: $attribute->getProductAttribute()->getFrontend()->getLabel()
//Attr-Id: $attribute->getProductAttribute()->getId()
}
return $result;
}
但是,如何从我们通过上述函数获得的可配置属性中使用现在可用的标签/ID 来获取该产品中使用的选项(如果可配置属性为“颜色”,则为蓝色、绿色、红色)?
答案非常感谢!
蒂姆