Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 缺货信息出现两次_Magento_Cart - Fatal编程技术网

Magento 缺货信息出现两次

Magento 缺货信息出现两次,magento,cart,Magento,Cart,出于某种原因,我的可配置产品在购物车页面上出现了两次“缺货”消息。我找到了这个Mage代码的错误消息: if ($this->getBackorders() == Mage_CatalogInventory_Model_Stock::BACKORDERS_YES_NOTIFY) { if (!$this->getIsChildItem()) { $result->setMessage( Mage::helper('catalogi

出于某种原因,我的可配置产品在购物车页面上出现了两次“缺货”消息。我找到了这个Mage代码的错误消息:

if ($this->getBackorders() == Mage_CatalogInventory_Model_Stock::BACKORDERS_YES_NOTIFY) {
    if (!$this->getIsChildItem()) {
        $result->setMessage(
            Mage::helper('cataloginventory')->__('This product is not available in the requested quantity. %s of the items will be backordered.', ($backorderQty * 1))
        );
    } else {
        $result->setMessage(
           Mage::helper('cataloginventory')->__('"%s" is not available in the requested quantity. %s of the items will be backordered.', $this->getProductName(), ($backorderQty * 1))
        );
    }
}
我收到了每一条信息。这就像它在两次检查同一个产品,一次是可配置的,一次是简单的


我认为这是一个配置问题,而不是代码中需要更改的内容。什么会导致这种奇怪的行为?

您是否重写了Mage\u Model\u CatalogInventory\u Observer类?您使用的是什么版本?

以下是我是如何做到这一点的
preg_将
message['text']
与backordered匹配并控制它。这是你的密码

    $i=0;
    foreach ($messages as $message):

      $txt= $message['text'] ;
      $re='(backordered)';  # Word 3

    if (preg_match_all ("/".$re."/is", $txt, $matches))
      { if($i == 0){?>
            <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']); ?></p>
     <?php }
     }
     else
     { ?>
      <p class="item-msg <?php echo $message['type'] ?>">* <?php echo $this->escapeHtml($message['text']) ?></p>
    <?php }
     $i++;
    endforeach;  
$i=0;
foreach($messages作为$message):
$txt=$message['text'];
$re='(延期交货);#单词3
if(preg_match_all(“/”$re./is“,$txt,$matches))
{如果($i==0){?>

您可以尝试添加一些var\u dump($this)或var\u dump($this->debug())语句临时插入到该核心文件中,以尝试确定其是否被多次调用。上面的逻辑不能同时运行两行。此外,请确保可配置的产品数量已正确设置。请为它们全部尝试0。尝试1。等等。如果不进入系统,将很难进行诊断。该代码运行两次,因此两次消息将被打印出来。一个用于简单产品(可配置产品的子产品),另一个用于可配置产品本身。您应该将其写在评论部分,而不是答案上。