我需要以Magento 1.7的价格出口所有产品。
对于简单产品,这没问题,但是对于可配置产品,我有以下问题:导出的价格是为相关简单产品设置的价格!如您所知,Magento会忽略此价格,而是使用可配置产品的价格以及所选选项的调整项。
我可以获得母产品的价格,但是如何根据所选的选项计算差异?
我的代码如下所示:
foreach($products as $p)
{
$price = $p->getPrice();
// I save it somewhere
// check if the item is sold in second shop
if (in_array($otherShopId, $p->getStoreIds()))
{
$otherConfProd = Mage::getModel('catalog/product')->setStoreId($otherShopId)->load($p->getId());
$otherPrice = $b2cConfProd->getPrice();
// I save it somewhere
unset($otherPrice);
}
if ($p->getTypeId() == "configurable"):
$_associatedProducts = $p->getTypeInstance()->getUsedProducts();
if (count($_associatedProducts))
{
foreach($_associatedProducts as $prod)
{
$p->getPrice(); //WRONG PRICE!!
// I save it somewhere
$size $prod->getAttributeText('size');
// I save it somewhere
if (in_array($otherShopId, $prod->getStoreIds()))
{
$otherProd = Mage::getModel('catalog/product')->setStoreId($otherShopId)->load($prod->getId());
$otherPrice = $otherProd->getPrice(); //WRONG PRICE!!
// I save it somewhere
unset($otherPrice);
$otherProd->clearInstance();
unset($otherProd);
}
}
if(isset($otherConfProd)) {
$otherConfProd->clearInstance();
unset($otherConfProd);
}
}
unset($_associatedProducts);
endif;
}