2016-01-23 62 views
2

基本上,我在SUPEE 7405更新後遇到了這個問題。每當我向購物車添加東西,然後點擊AJAX購物車中的刪除項目時,它都會告訴我「無法刪除該項目」。SUPEE 7405並且不能刪除購物車商品

我必須刷新頁面,然後項目才能成功刪除。 基本上添加,然後立即刪除item =不工作,我需要添加,刷新頁面(或轉到網站的其他頁面),然後單擊刪除。

我注意到貼片壓倒 應用程序/代碼/核心/法師/結帳/控制器/ CartController.php

代碼補丁後的補丁

/** 
* Delete shoping cart item action 
*/ 
public function deleteAction() 
{ 
    $id = (int) $this->getRequest()->getParam('id'); 
    if ($id) { 
     try { 
      $this->_getCart()->removeItem($id) 
       ->save(); 
     } catch (Exception $e) { 
      $this->_getSession()->addError($this->__('Cannot remove the item.')); 
      Mage::logException($e); 
     } 
    } 
    $this->_redirectReferer(Mage::getUrl('*/*')); 
} 

代碼之前

/** 
* Delete shoping cart item action 
*/ 
public function deleteAction() 
{ 
    if ($this->_validateFormKey()) { 
     $id = (int)$this->getRequest()->getParam('id'); 
     if ($id) { 
      try { 
       $this->_getCart()->removeItem($id) 
        ->save(); 
      } catch (Exception $e) { 
       $this->_getSession()->addError($this->__('Cannot remove the item.')); 
       Mage::logException($e); 
      } 
     } 
    } else { 
     $this->_getSession()->addError($this->__('Cannot remove the item.')); 
    } 

    $this->_redirectReferer(Mage::getUrl('*/*')); 
} 

在我的文件中修補程序覆蓋了什麼導致此問題?

回答

-2

在我的情況下編譯已啓用。所以我意識到編譯的文件不兼容或認可新補丁(SUPEE 7405)

我做了什麼?

  1. 刪除補丁sh patch_name.sh -R
  2. 禁用編譯
  3. 清除Magento的緩存
  4. 應用補丁再次sh patch_name.sh
  5. 清除Magento的緩存再次
  6. 啓用編譯
  7. 運行編譯過程

我希望幫助

+0

剛剛試了一下,反正,我的編譯是Disabled。感謝您的想法! – Icon

+0

這實際上爲我工作。謝謝! – rltegantvoort

0

正如你在deleteAction函數中看到的,SUPEE7405添加了表單鍵驗證到購物車刪除以防止惡意的跨站點請求。如果您已在主題中覆蓋購物車項目模板(checkout/cart/item/default.phtml),或者正在使用覆蓋此模板的主題,則需要更新其以包含formkey隱藏輸入字段。您可以從base/default/checkout/cart/item/default.phtml中抽取相關更改。

+0

您能告訴我哪個表單鍵正確/我應該使用哪個代碼? (我還在學習):) – Icon

+0

如果打開我鏈接到的文件('base/default/checkout/cart/item/default.phtml')和當前主題中的版本,則比較「刪除」按鈕,您會注意到base/default中的一個具有不同的HTML結構,使用包含表單鍵的onclick屬性。這就是您需要添加到您的模板版本中以與修補後的控制器保持一致。 –

+0

好的,我會嘗試並回復結果:) – Icon

2

您需要更新車項目模板[design_package /主題] /template/checkout/cart/item/default.phtml

查找<a href="<?php echo $this->getDeleteUrl() ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Remove Item')) ?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove Item') ?></a>

替換

<a href="<?php echo $this->getDeleteUrl() ?>form_key/<?php echo $formKey = Mage::getSingleton('core/session')->getFormKey();?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Remove Item')) ?>" class="btn-remove btn-remove2"><?php echo $this->__('Remove Item') ?></a> 
+0

感謝您的可能的解決方案。但它似乎沒有工作在我的情況下,因爲我已安裝ajax。我已經打開了一個不同的主題,解釋側欄刪除按鈕面臨的問題。 http://magento.stackexchange.com/questions/103764/supee-7405-add-form-key-to-sidebar-default-phtml – Icon