我正在制作一个magento网站(Magento ver.1.5.1.0) - 请回答我是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 / app / design / frontend / default / localsite / template / catalog / product / list / 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>
这就意味着我现在有一个畅销书排序选项,其排序方式与仪表板上的畅销书相同。不幸的是,仪表板的畅销书部分以及我的排序列表完全错误。
有没有人知道如何解决这个问题,或者失败,任何人都知道我可以排序的另一个属性,以达到相同的结果 - 如果我去仪表板&gt;报告&gt;产品&gt;产品订购我可以得到我想要的广泛的订单日期范围 - 在排序选项中重新创建此项的任何方法。
那里有可用的排序选项列表吗?
的 的 ** * ** * ** * 的** * ** * *** 更新的 * ** * ** * ** * ** * ** * *** < /强>
我现在已经注意到畅销书中列出的产品都是旧产品。已添加的最后100个左右的产品不包含在畅销书列表中。如果我在仪表板中使用a到Z排序或使用上面的排序选项,这些相同的产品也单独列出,这样他们就可以使用新产品A到Z,然后是旧产品A到Z.任何想法可能导致这种情况?
任何提示,建议,非常感谢。
答案 0 :(得分:1)
由于目录产品没有名为qty_ordered的属性,因此您不会有太多运气。无论您发生什么样的排序,都要么是行动中的二级排序列,要么是来自数据库的自然顺序。
后端使用Mage_Reports模块进行视图计数等。实现目标的最明显方法似乎是为您的产品添加自定义属性,并编写事件观察者以在销售时更新它。如果确保设置“用于产品列表中的排序”,它应该可以自动排序而不必覆盖任何核心类。
除此之外,我能想到的唯一的事情涉及很多复杂的类覆盖,很可能会在升级时破坏某些东西。