簡體   English   中英

為什么Magento在簡單地添加商品后會自動考慮將其丟棄?

[英]Why does Magento automatically consider a cart abandoned after simply adding an item to it?

一點背景

一位客戶正在使用Bronto向在Magento放棄購物車的站點訪問者發送電子郵件。 Bronto從Magento的報告中搶走了被遺棄的購物車。 客戶遇到的問題是,他注意到在Magento中作為訂單放置的購物車並未從廢棄的購物車報告中刪除,從而導致他意外地向已下訂單的客戶發送有關廢棄購物車的電子郵件。

我做了什么

我看了一下,試圖找到導致這種情況發生的一個主要原因,但我找不到任何原因。 我嘗試自己做一個測試訂單,發現將商品添加到購物車后,我的購物車就被視為廢棄的購物車。 我認為自己“很奇怪,如果我的會話過期並且我還沒有退房,這應該認為它已被放棄”。 我做了一些研究,看看是否有人遇到過同樣的問題,但是還是沒有運氣。 我下一步要做的就是打開“持久購物車”。 我啟用了持久性,但這沒有幫助,因為我的購物車仍在發送到“廢棄購物車”報告中。 即使在我結帳后,購物車仍保留在報告中。 然后,我創建了一個模塊,用於觀察sales_order_place_after事件。 該模塊在下訂單后檢查訂單,並取消創建訂單的報價(當用戶登錄時為“廢棄的購物車”)。 取消報價會從廢棄的購物車報告中刪除購物車。 這可以正常工作,但有些引號似乎會穿過裂縫,並且不會設置為非活動狀態(不確定原因)。

我的問題

1.為什么在將商品添加到購物車后,Magento會自動考慮將其丟棄?

2.我在哪里以及如何更改?

3.持久性購物車為什么不按規定做? (除非持久會話過期,或者我只是不了解持久購物車功能,否則請不要將購物車發送到廢棄的購物車,請解釋)

4.是什么導致某些引號不被我的模塊設置為非活動狀態?(我在下面顯示了代碼。config.xml和Observer.php)

5.我使用了正確的事件嗎?

config.xml中

<config> 
    <modules>
        <RIS_AbandonedCartCleanUp>
            <version>0.0.1</version>
        </RIS_AbandonedCartCleanUp>
    </modules>

    <global>

      <!-- Define the Model -->
      <models>
        <abandonedcartcleanup>
          <class>RIS_AbandonedCartCleanUp_Model</class>
        </abandonedcartcleanup>
      </models>

      <events>
        <sales_order_place_after>
          <observers>
            <abandonedcartcleanup>
              <type>singleton</type>
              <class>RIS_AbandonedCartCleanUp_Model_Observer</class>
              <method>remove_order_quote</method>
            </abandonedcartcleanup>
          </observers>
        </sales_order_place_after>
      </events>

    </global>

</config>

Observer.php

 <?php 

    class RIS_AbandonedCartCleanUp_Model_Observer{

    public function __construct(){
    }

    //Keep an eye out for when all the sales order saves have been committed
    public function remove_order_quote($observer){

        // Gets the order which is being saved.
        $order  = $observer->getOrder();
        $quoteId = $order->getQuoteId(); 

            //Get the quote for this specific order
        $quote = Mage::getModel('sales/quote')->load($quoteId);

            //Check if the quote is active
        if($quote->getIsActive() == 1){

              //set the quote to inactive and save
          $quote->setIsActive('0')
              ->save();
        }
    } 
    }

?>

我無法完全回答,但我會盡力而為。 首先,您說:

即使在我結帳后,購物車仍保留在報告中。

如果您對此非常確定,那么有些事情我將無法解釋,以下幾點可能沒有意義。

問題1

如果在app\\code\\core\\Mage\\Reports\\Model\\Resource\\Quote找到Collection.php並將其復制到app\\code\\local\\Mage\\Reports\\Model\\Resource\\Quote並添加

var_dump((string)$this->getSelect());

在prepareForAbandonedReport函數中(恰好在返回之前),您將看到Magento用於生成“放棄的購物車”報告的查詢。 就我而言,是:

SELECT `main_table`.*, (main_table.base_subtotal_with_discount*main_table.base_to_global_rate) AS `subtotal`, `cust_email`.`email`, `cust_fname`.`value` AS `firstname`, `cust_lname`.`value` AS `lastname`, CONCAT_WS(' ', cust_fname.value, cust_lname.value) AS `customer_name` 
    FROM `sales_flat_quote` AS `main_table` 
    INNER JOIN `customer_entity` AS `cust_email` ON cust_email.entity_id = main_table.customer_id 
    INNER JOIN `customer_entity_varchar` AS `cust_fname` ON cust_fname.entity_id = main_table.customer_id AND cust_fname.attribute_id = 5 
    INNER JOIN `customer_entity_varchar` AS `cust_lname` ON cust_lname.entity_id = main_table.customer_id AND cust_lname.attribute_id = 7 
    WHERE (items_count != '0') AND (main_table.is_active = '1')

如您所見,它不檢查任何日期或時間值。 如果其中有東西並且它是活動的,即它尚未被檢出,它只是考慮一個已放棄的推車。 (此外,有趣的是,從未登錄的用戶中查找廢棄的購物車也不會麻煩。)

換句話說,推車被認為是廢棄的,直到被檢出。 即使已完成訂單但仍收到電子郵件的客戶,可能在結賬前就已由Bronto排隊等候電子郵件。

問題2

您可以通過為“ updated_at在會話到期時間之前”添加一些條件來修改上述查詢,但這可能只會更改報告,而不是Bronto的操作,因為Bronto可能正在使用自己的查詢。 他們聲稱可以發現來賓用戶遺棄的購物車這一事實似乎表明了這一點。

問題3

http://www.magentocommerce.com/knowledge-base/entry/setting-up-a-persistent-shopping-cart上 ,它說:

持久的購物車會跟蹤購物車中剩余的未購買商品,並保存信息以供客戶下次訪問。

我認為這幾乎就是全部。 持久性購物車僅在用戶返回時保存。 這本身與他們被遺棄的地位並不矛盾。

問題4和5

據我所知,您的代碼看起來不錯。 但是,實際上沒有必要將報價設置為非活動狀態。 Magento默認情況下應該注意這一點,如果不這樣做,就像我在開始時說的那樣,您正在發生某些事情,我無法立即解釋

+1表示您對問題B​​TW的注意。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM