我需要收集給定產品的所有可用屬性,然後使用它們創建多維數組。希望你可以創建一個具有兩個以上維度的多維數組?結果數組的聲明應該是這樣的:Magento將屬性收集爲多維數組鍵
$simpleArray[$child->getVendor()][$child->getColor()]=$child->getPrice();
首先,我收集的所有屬性,然後將其添加到字符串,我可以調用每一個後來:
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
//Gather all attribute labels for given product
foreach($_attributes as $_attribute){
$attributeString .= '[$child -> get' . ucfirst($_attribute->getLabel()) . '()]';
}
然後我試圖將該字符串附加到數組以聲明它:
foreach($childProducts as $child) { //cycle through simple products to find applicable
//CAITLIN you are going to need way to search for other attributes, GET list of attributes
$simpleArray. $attributeString =$child->getPrice();
}
Mage::log('The attributeString is '. $simpleArray. $attributeString, null, 'caitlin.log'); //This is logging as "The attributeString is Array74"
有什麼建議嗎?
你試圖讓你的價格圖出magento? –
這是我對它的理解,我在回答中做了一些非常顯着的改變,因爲使用for循環在嘗試向後「生成未知深度的多級數組」時變得非常簡單。 –