2012-02-13 29 views
2

我工作的一個Magento站點(Magento的版本1.5.1.0) - 普萊舍注意在回答我是新來的Magento。 我想獲得一個選項,以暢銷書排序我已經設法通過添加本地文件覆蓋核心文件,如下所示:Magento的暢銷書不工作 - 尋求修訂或變通方法

httpdocs /應用程序/代碼/本地/法師/目錄/塊/產品/列表/ Toolbar.php:

public function getAvailableOrders() 
{ 
    //return $this->_availableOrder; 
    //Custom Order list Edit 
    $this->_availableOrder = array(
     'qty_ordered' => $this->__('Best Sellers'), 
     'entity_id' => $this->__('Latest arrivals'), 
     'name' => $this->__('Name'), 
     'price' => $this->__('Price') 
    ); 
    //Custom Available Order -Edit finish 
    return $this->_availableOrder; 
} 

而且的httpdocs /應用程序/設計/前端/默認/ localsite /模板/目錄/產品/列表/ toolbar.phmtl:

<fieldset class="sort-by"> 
    <label><?php echo $this->__('Sort by') ?></label> 
    <select onchange="setLocation(this.value)"> 
     <option value="<?php echo $this->getOrderUrl('entity_id', 'desc') ?>"<?php if($this->isOrderCurrent('entity_id') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> 
      Newest Products 
     </option> 
     <option value="<?php echo $this->getOrderUrl('qty_ordered', 'desc') ?>"<?php if($this->isOrderCurrent('qty_ordered') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> 
      Best Sellers 
     </option> 
     <option value="<?php echo $this->getOrderUrl('price', 'asc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> 
      Lowest Price 
     </option> 
     <option value="<?php echo $this->getOrderUrl('price', 'desc') ?>"<?php if($this->isOrderCurrent('price') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> 
      Highest Price 
     </option> 
     <option value="<?php echo $this->getOrderUrl('name', 'asc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'asc'): ?> selected="selected"<?php endif; ?>> 
      Name A-Z 
     </option> 
     <option value="<?php echo $this->getOrderUrl('name', 'desc') ?>"<?php if($this->isOrderCurrent('name') && $this->getCurrentDirection() == 'desc'): ?> selected="selected"<?php endif; ?>> 
      Name Z-A 
     </option> 
    </select> 
</fieldset> 

這個工作的意義我現在有暢銷書排序選項,其排列方式與暢銷書排序方式相同在儀表板上。不幸的是,儀表板的暢銷書部分以及我的排序列表完全是錯誤的。

有誰知道如何解決這個或失敗,沒有人知道另一個屬性,我可以通過實現相同的結果 - 如果我去儀表板>報告>產品>產品有序我可以得到我想要的訂單廣泛的日期範圍 - 任何方式在排序選項中重新創建它。

是否有可用的排序選項列表,在某處?

** * ** * ** * ** * ** * ***UPDATE* ** * ** * ** * ** * ** * ***

我現在已經注意到,暢銷書中列出的產品都是舊產品。最近添加的100個左右產品不包含在暢銷書列表中。這些相同的產品也被單獨列出來,如果我在儀表板中或者使用上面的排序選項來排序,那麼它們會將新產品從A到Z,然後是老產品A到Z.任何想法可能會導致這種情況?

任何提示,建議,非常感謝幫助。

+0

@Josh卡斯威爾感謝您對此事的關注,並緩慢回覆對不起 - 我已經回答您的評論更新的問題 - 希望這個新的信息會有所幫助。 – WebweaverD 2012-02-21 16:05:15

回答

1

由於目錄產品沒有叫qty_ordered的屬性,你就沒有多少運氣的方式。無論您看到的是什麼次序,都可以是次級排序列或數據庫自然排序。

的後端使用用於觀看次數等的Mage_Reports模塊。實現目標的最明顯方式似乎是在產品中添加自定義屬性,並編寫事件觀察器以在銷售時進行更新。如果確保設置「用於在產品清單中排序」,則應該可以自動進行排序,而無需覆蓋任何核心類。

除此之外,我能想到的唯一的事情涉及到很多複雜的類覆蓋的是將在升級很可能碰壞。

+0

謝謝你的回答。正如我在我的問題中所說的,我是Magento的新手,所以我不確定如何實施您的建議。我會做一些研究,看看我能得到多少建議。 – WebweaverD 2012-02-27 14:03:11

+0

我發現[本文](http://codemagento.com/2011/04/observers-and-dispatching-events/)對理解如何使用事件觀察器系統非常有幫助。基本上,您需要創建一個簡單的模塊,其中包含一個config.xml,一個用於添加屬性的設置腳本以及一個事件觀察者。我知道這看起來令人望而生畏,但並不像看起來那麼難。祝你好運! – wierdo 2012-02-27 21:02:33

+0

謝謝你的聯繫,本週我會有一個破解,並希望凱旋歸來。 – WebweaverD 2012-02-29 19:04:41