【问题标题】:How to sort products by last price change? in Magento 1.9如何按上次价格变化对产品进行排序?在 Magento 1.9 中
【发布时间】:2019-02-01 16:36:21
【问题描述】:

我们最近有很多价格变化,我刚刚更改了我们基本的 1.9 magento 商店的价格。现在我希望能够根据以下内容对产品进行分类: 最新的价格变化/最新的日期/时间变化。所以我可以浏览列表,看看它们是否都被正确更改。我应该如何进行?

  1. Captain Obvious:聘请一名程序员/网络开发人员。
  2. 我想这类似于这个主题:Magento - Sort by Date Added,根据答案可以在不更改核心文件的情况下进行。

是的,你猜对了,我希望使用选项 2。现在可以简单地完成吗?

我不是编码员或网络开发人员,但我确实具备基本的网络知识和 ftp 访问权限。

【问题讨论】:

    标签: sorting date magento time


    【解决方案1】:

    在您的收藏中使用 update_at 排序

    示例

    $collection = Mage::getResourceModel('catalog/product_collection');
    $collection->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
    $collection->addAttributeToSort('updated_at', 'desc');
    

    【讨论】:

      【解决方案2】:

      由于您只想执行验证,因此可以在管理员端完成。

      您可以在目录产品网格中显示更新时间

      在自定义模块中,我们将其设置为 config.xml

      <config>
          <global>
              <blocks>
                  <adminhtml>
                     <rewrite>
                         <catalog_product_grid>Vendor_Module_Block_Adminhtml_Catalog_Product_Grid</catalog_product_grid>
                     </rewrite>
                 </adminhtml>
              </blocks>
          </global>
      </config>
      

      然后在app/code/local/&lt;VENDOR&gt;/&lt;MODULE&gt;/Block/Adminhtml/Catalog/Product/Grid.php

      <?php
      
      class Vendor_Module_Block_Adminhtml_Catalog_Product_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
      {
      
          public function setCollection($collection)
          {
              /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
              // IF the attribute `updated_at` is already in the collection,
              // THEN you can remove this function,
              // ELSE uncomment this line :
              // $collection->addAttributeToSelect('updated_at');
      
              parent::setCollection($collection);
          }
      
          protected function _prepareColumns()
          {
              $store = $this->_getStore();
              // after column price :
              $this->addColumnAfter('updated_at',
                  array(
                      'header'=> Mage::helper('sales')->__('Updated At'),
                      'header_css_class'  => 'a-center',
                      'type'  => 'datetime',
                      'index' => 'updated_at',
                      'sortable'=>true,
                  ),
                  'price'
               );
      
              return parent::_prepareColumns();
          }
      }
      

      我还没有测试,但它应该可以工作。

      然后,您将能够对这个新列上的网格进行排序。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多