如何更改magento中产品的显示顺序

发布于 2024-10-14 18:06:07 字数 154 浏览 4 评论 0原文

如何通过从后端设置一些首选项来更改前端(网格或列表)中的产品显示顺序?我想它应该不是默认 Magento 显示顺序属性中的最佳值和名称。

我尝试创建一个名为 display_order 的新属性,每个产品根据其需要在前端显示的值保存一个值。但是,它不起作用。请帮我解决这个问题。

How can I change the product display order in the front end (grid or list) by setting some preferences from back-end? I guess it should be other than best value and name from the default Magento display order property.

I tried by creating a new attribute called display_order, and each product holds a value based on its value the product needs to shown in front end. However, it is not working. Please help me fix this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

埖埖迣鎅 2024-10-21 18:06:07

您需要扩展 Mage_Catalog_Block_Product_List 块,以便为 getProductCollection() 方法提供您自己的功能。可能是这样的:

class ... extends Mage_Catalog_Block_Product_List {
    function getProductCollection() {
        parent::getProductCollection()->addAttributeToSort('display_order', 'ASC')
    }
}

然后,当然,您必须更新您的自定义控制器上的布局 xml 文件(除非您希望所有产品列表屏幕都像这样)以使用您的新块Magento 默认的 catalog/product_list

You'll need to extend the Mage_Catalog_Block_Product_List block to provide your own functionality for the getProductCollection() method. Probably something along the lines of:

class ... extends Mage_Catalog_Block_Product_List {
    function getProductCollection() {
        parent::getProductCollection()->addAttributeToSort('display_order', 'ASC')
    }
}

Then, of course, you'll have to update you layout xml file on your, presumably, custom controller (unless you want all of the product listing screens to act like this) to use your new block instead of the Magento default of catalog/product_list.

天涯沦落人 2024-10-21 18:06:07

你为什么不使用 Magento 排序工具呢?

在您的类别中,在类别产品下,您可以在最后一列中选择排序顺序。要通过 php 执行此操作,只需创建一个需要启动一次的自定义脚本。

$collection = 'Your product collection';
$result = array();
foreach ($collection as $product) {
   $sort = 'Your way of calculating the desired sorting';
   $result[$product->getId()]=$sort;
}
Mage::getModel('catalog/category')->load('your category id')->setPostedProducts($result)->save();

就是这样:)

Why don't you use the Magento sorting thing ?

In your category, under Category Product you have the possibility to choose the sorting order in the last column. To do it through php, just make a custom script that you'll need to launch once.

$collection = 'Your product collection';
$result = array();
foreach ($collection as $product) {
   $sort = 'Your way of calculating the desired sorting';
   $result[$product->getId()]=$sort;
}
Mage::getModel('catalog/category')->load('your category id')->setPostedProducts($result)->save();

And that's it :)

油饼 2024-10-21 18:06:07

要更改显示顺序,首先您需要将默认排序方式选项设置为位置。这可以通过 magento 管理配置完成。之后,您需要为所有以值 1 开头的产品设置位置。

我遇到了以下模块将使此任务变得非常简单,只需从管理类别本身拖放产品即可。请检查以下扩展

http://www.blackqubers.com/extensions/product-sorting-drag-and-drop.html

希望这会对您有所帮助

To change the display order , first you need to set the default sort by option to position.This can be done from the magento admin configuration.After that you need to set position for all the products starting with the value 1.

I come across the following module which will make this task very easy, just by drag and drop the products from the manage categories itself.Please check the following extension

http://www.blackqubers.com/extensions/product-sorting-drag-and-drop.html

Hope this will helps you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文