私は既によくわかりました、そして、実際には、私のカテゴリリストをstock_statusでソートしました。他の言葉私は底に在庫切れの商品があります。 しかし、私は在庫切れの製品のその部分をソートするために私の前にいくつかのコードを挿入する必要があります。例えばMagento 1.9 - 二重条件で製品を2回ソートする方法は?
:私は在庫品でソートする必要があるため
Product4
Product5
Product6
Product1
Product2
Product3
これは私のために素晴らしいです:
Product1 have Qty=0 and product_views attribute=97
Product2 have Qty=0 and product_views attribute=902
Product3 have Qty=0 and product_views attribute=75
Product4 have Qty=35 and product_views attribute=1500
Product5 have Qty=398 and product_views attribute=5298
Product6 have Qty=275 and product_views attribute=17
今私は、ソート名前であれば、これは結果持っています名前(または通常はフロントエンドの任意の他の選択肢)でも、同時に私はproduct_views属性で在庫商品を並べ替える必要があります。
そして私はリストを持っている必要があります(私は、例えば名前でフロントエンドの並べ替えに選択した場合)、次のように並べ替え:
Product4
Product5
Product6 (this is in stock products that because it must be sorted as usually based on choice of selectbox in frontend)
Product2
Product1
Product3 (this is out of stock products that because it must be sorted by product_views attrubute - most viewed in top)
今私は2番目の並べ替えレベル(と私のためにこのコードを使用)product_viewsで1つのレベルのソートを見つける私を助けるためにあなたを求めるしかし、唯一の在庫商品のうちをソートする必要があります。
try {
$websiteId = Mage::app()->getStore()->getWebsiteId();
if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
$stockStatusFieldExisted = Mage::helper('webpiercom_outofstockmastmndmostviewed_catalog')->checkFieldExisted($collection->getSelect(), 'stock_status');
if(!$stockStatusFieldExisted) {
$collection->joinTable(
array('wprdc' => 'cataloginventory/stock_status'),
'product_id=entity_id',
array('stock_status'),
array('website_id' => $websiteId),
'left'
);
}
}
$collection->getSelect()->order('stock_status desc');
}
主にアップデートタイトル –
どういう意味ですか? –
申し訳ありません –