經過幾個小時的試用不同的解決方案我採取了在管理區域內配置保存過程後,這指出我下面的方法;
Mage_Catalog_Model_Product_Type_Configurable::save
後來我發現,保存配置時,編程getConfigurableAttributesData和getConfigurableProductsData都是空的。 這導致我創建了一個定製shell腳本,其中我加載了一組可配置的產品,循環並重新保存了數據;
foreach($_collectionConfigurables as $_configurableProduct){
// flag to be saved
$_configurableProduct->setCanSaveConfigurableAttributes(1);
// get the configurable attributes
$_configurableAttributes = $_configurableProduct->getTypeInstance()->getConfigurableAttributesAsArray();
$_configurableProduct->setConfigurableAttributesData($_configurableAttributes);
// Build a collection of configurable children
$_collectionChildren = $_configurableProduct->getTypeInstance()->getUsedProducts();
// loop the children and save configurable attributes into an array
$arr = array();
foreach($_collectionChildren as $_childProduct){
foreach($_configurableAttributes as $_attr){
$arr[$_childProduct->getId()][] = array(
'attribute_id' => $_attr['attribute_id'],
'label' => $_childProduct->getAttributeText($_attr['attribute_code']),
'value_index' => $_childProduct->getData($_attr['attribute_code'])
);
}
}
$_configurableProduct->setConfigurableProductsData($arr);
$_configurableProduct->save();
echo "{$_configurableProduct->getId()}\n";
}
請注意,這已審結和CE 1.9.2.1
我也有這個問題(通過StoreManager)測試,你碰巧發現到Magmi替代? – 2015-10-13 14:23:39
不,這時magmi對我來說工作得很好。在這個項目之後,我決定再也不和Magento一起工作,而且我沒有^^很抱歉,我無法幫到你。 – Armin 2015-10-13 14:28:48