2013-03-05 31 views
1

我有一個maganto安裝(1.4.0.1)與幾個網站和幾個商店/商店的看法。此外,我在所有商店的意見中有不同的產品。當我離開我的賬戶時 - >我的表中的訂單顯示所有商店的訂單。我可以在某處配置或更改代碼中的某些內容,以便從當前的開放式商店視圖中獲得訂單清單?「我的訂單」表只是從當前的商店視圖訂單

換句話說,如果我在我的網站mywebsite.com/store2上訂購mywebsite.com/store2/sales/order/history/,它會顯示所有網站的訂單歷史記錄,但我需要我只需要顯示「store2」的訂單。

我希望有人爲這個或類似問題的答案,我會很感激,如果幫助我。

約旦

回答

2
/*GetCurrent Website Name*/ 
    $currentWebsiteName = Mage::app()->getStore()->getWebsite()->getName();   
    $currentWebsiteName_LIKE_PHRASE = '%'.$currentWebsiteName.'%'; 

    /*Filter the Order Collection by Current Website Name*/ 
    $orders = Mage::getResourceModel('sales/order_collection') 
     ->addFieldToSelect('*') 
     ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()) 
     ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) 
     ->addAttributeToFilter('store_name', array('like' => $currentWebsiteName_LIKE_PHRASE)) 
     ->setOrder('created_at', 'desc'); 

    /*Note the Below Line*/ 
    ->addAttributeToFilter('store_name', array('like' => $currentWebsiteName_LIKE_PHRASE)) 

上午過濾通過的電流的網站名稱。剛剛拿到sales_flat_order表可以查看本專欄'store_name'您可以在其中找到它也包含網站名稱

可惜我不能找到這個主順序表或在其相關表網站ID做出JOIN語句的順序收集。我認爲你可能會有一些訂單表與** _網站後綴**,如果是這種情況下,你可以輕鬆地加入到我們現有的集合

+0

謝謝,這是什麼需要我。 :) – 2013-03-06 07:41:28

2

很簡單。

覆蓋各個銷售訂單的歷史塊的應用程序\代碼\核心\法師\銷售\塊\訂單\ History.php文件到你當地的號碼池

,只是由當前存儲ID篩選您的收藏。

   $store_id = Mage::app()->getStore()->getId(); 
      $orders = Mage::getResourceModel('sales/order_collection') 
     ->addFieldToSelect('*') 
     ->addFieldToFilter('customer_id', Mage::getSingleton('customer/session')->getCustomer()->getId()) 
     ->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates())) 
     ->addFieldToFilter('store_id',$store_id) 
     ->setOrder('created_at', 'desc') 
    ; 

注意這些行以上代碼

 /*Current Store View ID*/ 
     $store_id = Mage::app()->getStore()->getId(); 

     /*Filtering the order collection by current store id*/ 
     ->addFieldToFilter('store_id',$store_id) 
+0

非常感謝,它的工作很好,但現在我需要更改爲列表我試過用$ website_id = Mage :: app() - > getStore() - > getWebsiteId();和addFieldToFilter('website_id',$ website_id),但不工作,一些建議 – 2013-03-05 10:38:59

+0

@JovanovJordan顯然訂單集合不能由website_id來訂購,因爲它沒有它。此外,我們已經通過store_id過濾了集合,集合僅包含該商店視圖的訂單。 – Haijerome 2013-03-05 11:13:05

+0

嗨再次,但我想刪除選擇表單store_id並選擇網站。一些建議在另一種方式 – 2013-03-05 12:06:25

相關問題