質問

製品名によって自宅で新製品を並べ替える方法?

画像の説明が入力されています

管理者のCMSページを通過させるのがわかりました:

addin - CMSページ - ホーム - コンテンツ:

{{widget type="catalog/product_widget_new" display_type="new_products" products_count="4" column_count="4" template="catalog/product/widget/new/content/new_grid.phtml"}}
.

役に立ちましたか?

解決

ローカルフォルダにClass Mage_Catalog_Block_Product_Widget_Newを取るか、またはそれを自分の

で拡張します。

下記関数を探す

protected function _getProductCollection()
    {
        switch ($this->getDisplayType()) {
            case self::DISPLAY_TYPE_NEW_PRODUCTS:
                $collection = parent::_getProductCollection();
                break;
            default:
                $collection = $this->_getRecentlyAddedProductsCollection();
                break;
        }

        return $collection;
    }
.

とこの

に置き換える
protected function _getProductCollection()
    {
        switch ($this->getDisplayType()) {
            case self::DISPLAY_TYPE_NEW_PRODUCTS:
                $collection = parent::_getProductCollection();
                break;
            default:
                $collection = $this->_getRecentlyAddedProductsCollection();
                break;
        }
        $collection->addAttributeToSort('name');
        return $collection;
    }
.

他のヒント

からのBellow関数を更新してください:

protected function _getProductCollection()
    {
        switch ($this->getDisplayType()) {
            case self::DISPLAY_TYPE_NEW_PRODUCTS:
                $collection = parent::_getProductCollection();
                break;
            default:
                $collection = $this->_getRecentlyAddedProductsCollection();
                break;
        }
        return $collection;
    }
.

protected function _getProductCollection()
{
    switch ($this->getDisplayType()) {
        case self::DISPLAY_TYPE_NEW_PRODUCTS:
            $collection = parent::_getProductCollection();
           $collection->addAttributeToSort('name', 'ASC');
            //or $collection->addAttributeToSort('name', 'desc'); 
            break;
        default:
            $collection = $this->_getRecentlyAddedProductsCollection();
            break;
    }
    return $collection;
.

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top