Magento 为所有简单产品都已启用映射的组产品应用映射
我们与Magento有一个问题,当所有简单产品都启用了地图功能时,一个组产品(在搜索、目录等中)显示其价格为“起始价:$XX.XX” 我们希望价格显示类似“添加到购物车以查看价格”的内容 我在代码中找到了两个可能的位置 app/code/core/Mage/Catalog/Block/Product/Abstract.php中的第一个Magento 为所有简单产品都已启用映射的组产品应用映射,magento,Magento,我们与Magento有一个问题,当所有简单产品都启用了地图功能时,一个组产品(在搜索、目录等中)显示其价格为“起始价:$XX.XX” 我们希望价格显示类似“添加到购物车以查看价格”的内容 我在代码中找到了两个可能的位置 app/code/core/Mage/Catalog/Block/Product/Abstract.php中的第一个 public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix =
public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '')
{
$type_id = $product->getTypeId();
if (Mage::helper('catalog')->canApplyMsrp($product)) {
$realPriceHtml = $this->_preparePriceRenderer($type_id)
->setProduct($product)
->setDisplayMinimalPrice($displayMinimalPrice)
->setIdSuffix($idSuffix)
->toHtml();
$product->setAddToCartUrl($this->getAddToCartUrl($product));
$product->setRealPriceHtml($realPriceHtml);
$type_id = $this->_mapRenderer;
}
return $this->_preparePriceRenderer($type_id)
->setProduct($product)
->setDisplayMinimalPrice($displayMinimalPrice)
->setIdSuffix($idSuffix)
->toHtml();
}
如果我在返回之前知道我是否注释了If语句,或者只是将$temp_id设置为msrp,那么它将起作用(但适用于所有产品)
因此,我需要在上面的函数中添加一些代码来检查是否所有相关产品都启用了MAP,或者更改函数canApplyMsrp来检查这一点
app/code/core/Mage/Catalog/Helper/Data.php
public function canApplyMsrp($product, $visibility = null, $checkAssociatedItems = true)
{
if (!$this->isMsrpEnabled()) {
return false;
}
if (is_numeric($product)) {
$product = Mage::getModel('catalog/product')
->setStoreId(Mage::app()->getStore()->getId())
->load($product);
}
if (!$this->canApplyMsrpToProductType($product)) {
return false;
}
$result = $product->getMsrpEnabled();
if ($result == Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Enabled::MSRP_ENABLE_USE_CONFIG) {
$result = $this->isMsrpApplyToAll();
}
if (!$product->hasMsrpEnabled() && $this->isMsrpApplyToAll()) {
$result = true;
}
if ($result && $visibility !== null) {
$productVisibility = $product->getMsrpDisplayActualPriceType();
if ($productVisibility == Mage_Catalog_Model_Product_Attribute_Source_Msrp_Type_Price::TYPE_USE_CONFIG) {
$productVisibility = $this->getMsrpDisplayActualPriceType();
}
$result = ($productVisibility == $visibility);
}
if ($product->getTypeInstance(true)->isComposite($product)
&& $checkAssociatedItems
&& (!$result || $visibility !== null)
) {
$resultInOptions = $product->getTypeInstance(true)->isMapEnabledInOptions($product, $visibility);
if ($resultInOptions !== null) {
$result = $resultInOptions;
}
}
return $result;
}
任何帮助都将不胜感激
谢谢。将函数getPriceHTML更改为:
public function getPriceHtml($product, $displayMinimalPrice = false, $idSuffix = '')
{
$type_id = $product->getTypeId();
if (Mage::helper('catalog')->canApplyMsrp($product)) {
$realPriceHtml = $this->_preparePriceRenderer($type_id)
->setProduct($product)
->setDisplayMinimalPrice($displayMinimalPrice)
->setIdSuffix($idSuffix)
->toHtml();
$product->setAddToCartUrl($this->getAddToCartUrl($product));
$product->setRealPriceHtml($realPriceHtml);
$type_id = $this->_mapRenderer;
}
else if ($type_id == 'grouped')
{
$all_map = true;
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
foreach ($associatedProducts as $simpleProduct)
{
if (!Mage::helper('catalog')->canApplyMsrp($simpleProduct)) {
$all_map = false;
break;
}
}
if ($all_map)
{
$realPriceHtml = $this->_preparePriceRenderer($type_id)
->setProduct($product)
->setDisplayMinimalPrice($displayMinimalPrice)
->setIdSuffix($idSuffix)
->toHtml();
$product->setAddToCartUrl($this->getAddToCartUrl($product));
$product->setRealPriceHtml($realPriceHtml);
$type_id = $this->_mapRenderer;
}
}
return $this->_preparePriceRenderer($type_id)
->setProduct($product)
->setDisplayMinimalPrice($displayMinimalPrice)
->setIdSuffix($idSuffix)
->toHtml();
}
似乎是他们干的。有人看到这种技术有什么问题吗?我的解决方案似乎不适用于相关产品中的网格,或者在查看购物车时“您可能还需要”