2014-02-10 68 views
0

概述:加入購物車錯誤,產品重定向問題 - Magento的

在我的產品叫測試產品有量。

enter image description here

所以,當我把數量,並按添加到購物車。 (記住,產品的數量是10,所以它應該提示錯誤)

enter image description here

輸出是正確的,用戶得到了通過,他們不是比數量放時,該系統通知產品的實際數量。

enter image description here

如果在URL仔細一看,用戶之前單擊添加到購物車,網址是

enter image description here

當已經顯示的錯誤,網址是

enter image description here

含義,magento刪除類別鏈接並重定向到t他實際的產品鏈接。

問題 有沒有什麼辦法了Magento的重定向到當前的類別,而不是產品的鏈接?

回答

0

默認情況下,重定向到類別或包含在URL中的類別的產品都是不可能的。你需要爲此編寫一個模塊。

讓我們看看重定向在代碼中完成的位置,因此可以修改行爲。 從購物車控制器產品開始添加到購物車Mage_Checkout_CartController::addAction()。該產品加入

$cart = $this->_getCart(); 
... 
$cart->addProduct($product, $params); 

具有Mage_Checkout_Model_Cart::addProduct()仔細看看產品與庫存量不足的重定向URL設置的位置:

/** 
* String we can get if prepare process has error 
*/ 
if (is_string($result)) { 
$redirectUrl = ($product->hasOptionsValidationFail()) 
    ? $product->getUrlModel()->getUrl(
     $product, 
     array('_query' => array('startcustomization' => 1)) 
    ) 
    : $product->getProductUrl(); 
$this->getCheckoutSession()->setRedirectUrl($redirectUrl); 
if ($this->getCheckoutSession()->getUseNotice() === null) { 
    $this->getCheckoutSession()->setUseNotice(true); 
} 
Mage::throwException($result); 
} 

這裏的產品被下載,而分類信息這樣的類別不是這個網址的一部分。

相關問題