0

以下のコードを使用して、最後に表示したアイテムのリストにアクセスしようとしています:

 $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
 $model = Mage::getModel('reports/product_index_viewed');
 //
 $_collection = $model->getCollection()->addAttributeToSelect($attributes)
                  ->excludeProductIds($model->getExcludeProductIds())
                  ->addUrlRewrite()
                  ->setPageSize($columnCount)
                  ->setCurPage(1);
 //
 $_collection->addPriceData();
 $_collection->addIndexFilter();
 $_collection->setAddedAtOrder();
 //
 Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($_collection);

これを Mage_Reports_Block_Product_Abstract からコピーしましたが、これは作成順に製品を提供しています。

4

1 に答える 1

0

プラサントがこれに戻ることはないと思いますが、私も、常に利用できるとは限らないブロックを使用せずに製品の簡単なリストを取得しようとしていました. 最終的に、これが必要であることがわかりました:

$viewedCollection = Mage::getModel('reports/product_index_viewed')
                    ->getCollection()
                    ->addIndexFilter();

シークレットは にありaddIndexFilter()、現在の顧客を使用するか、ログインしていない場合は現在の訪問者を代わりに使用します。これから、他のコレクションと同様にループするか、単一の配列を抽出できます。

$viewedProductIds = $viewedCollection->getColumnValues('product_id');
于 2012-12-08T19:35:51.573 に答える