Magento社区致命错误代码调用成员函数getAttributeid()on boolean on ...第108行

时间:2017-01-31 21:50:21

标签: php magento

我正在尝试在Magento CE 1.9上添加一个可配置产品,我遇到致命错误:在布尔上调用成员函数getAttributeid()......第108行

这是第108行:

if ($attribute->getAttributeId() == $listSwatchAttr->getAttributeId()

        }

        /* @var $parentProduct Mage_Catalog_Model_Product */
        foreach($parentProducts as $parentProduct) {
            $mapping = array();
            $listSwatchValues = array();

            /* @var $attribute Mage_Catalog_Model_Product_Type_Configurable_Attribute */
            foreach($attributeCollection as $attribute) {
                /* @var $childProduct Mage_Catalog_Model_Product */
                if(!is_array($parentProduct->getChildrenProducts())) {
                    continue;
                }

                foreach($parentProduct->getChildrenProducts() as $childProduct) {
                    $attributeValue = $childProduct->getData($attribute->getAttributeCode());

                    if(empty($attributeValue)) {
                        continue;
                    }

                    $attributeLabel = null;
                    if(!isset($attributeLabels[$attributeValue])) { //no label at all
                        continue; //skip
                    }
                    if(isset($attributeLabels[$attributeValue][$storeId])) { //prefer store-specific value
                        $attributeLabel = $attributeLabels[$attributeValue][$storeId];
                    } else if(isset($attributeLabels[$attributeValue][0])) { //fall back to default value
                        $attributeLabel = $attributeLabels[$attributeValue][0];
                    }

                    if(!isset($mapping[$attributeLabel])) {
                        $mapping[$attributeLabel] = array();
                    }
                    $mapping[$attributeLabel][] = $childProduct->getId();
                    $mapping[$attributeLabel] = array_unique($mapping[$attributeLabel]);

                    if ($attribute->getAttributeId() == $listSwatchAttr->getAttributeId()
                        && !in_array($attributeLabel, $listSwatchValues)) {
                        $listSwatchValues[$attributeValue] = $attributeLabel;
                    }
                } //end looping child products
            } //end looping attributes

            $parentProduct->setChildAttributeLabelMapping($mapping)
                ->setListSwatchAttrValues($listSwatchValues);
        } //end looping parent products
    }      

我知道如何解决这个问题吗?

0 个答案:

没有答案