2013-01-09 44 views
0

出於某種原因,我的可配置產品在購物車頁面上出現兩次「延期訂單」消息。我追查到這個法師代碼的錯誤信息:延期消息出現兩次

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)) 
     ); 
    } 
} 

我收到了這些消息。這就像它爲相同的產品檢查兩次,一次爲可配置,一次爲簡單。

我想這是在代碼中,我應該需要更改配置問題,而不是東西。什麼會導致這種奇怪的行爲?

+0

您可以嘗試添加一些的var_dump($本)或後續代碼var_dump代碼($這個 - >調試())語句轉換核心文件暫時試圖找出如果被多次調用。上面的邏輯不能同時運行這兩行。 此外,請確保可配置的產品數量已正確設置。全部嘗試0。嘗試1.等。如果沒有進入你的系統,這將是很難診斷。 – CarComp

+0

該代碼運行兩次,因此將打印兩條消息。一個用於簡單產品(可配置產品的子代),另一個用於可配置產品本身。 –

回答

0

你重寫了Mage_Model_CatalogInventory_Observer類嗎?和你使用的是什麼版本?

+2

你應該在評論部分寫下這些而不是回答。 – bot

0

這是我是如何做到的。 preg_matchmessage['text']與延期交貨和控制它。這裏是你

$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;