工作环境综述
我正在一个我们有客户和经销商的网站上工作.每个经销商都可以为产品定价.
生产收集数据具有另一个具有该卖方价格的产品的重复记录(克隆产品).例如,如果主目录有IPHONE 6S.超过5个交易Iphone 6s的经销商可以有自己的价格.克隆产品会创建与卖家ID相关的新产品ID
需求
我需要获得具有最低价格的经销商的类别明智的产品列表.还需要根据最低价格对该列表进行排序.
我尝试了什么
目前我可以根据类别列出所有价格最低的产品.
$productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('sellingprice')
->setStoreId($storeId)
->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id=entity_id', null, 'left')
->addAttributeToFilter('category_id', array('in' => $_POST['category_id']))
->addAttributeToFilter('status', array('eq' => 1))
->addAttributeToFilter('dis_continue', array('eq' => 0));
$productCollection->addAttributeToFilter('seller_id', array('in' => $seller_list));
$productCollection->addExpressionAttributeToSelect(
'lowest_price', 'IF(({{special_from_date}}<=now() AND {{special_to_date}}>=now() OR {{special_from_date}} IS NULL AND {{special_price}}>0),{{special_price}},IF({{sellingprice}}>0,{{sellingprice}},{{price}}))', array('special_from_date', 'special_to_date', 'special_price', 'sellingprice', 'price'));
$productCollection->getSelect()->columns('MIN(IF((IF(at_special_from_date.value_id > 0, at_special_from_date.value, at_special_from_date_default.value)<=now() AND IF(at_special_to_date.value_id > 0, at_special_to_date.value, at_special_to_date_default.value)>=now() OR IF(at_special_from_date.value_id > 0, at_special_from_date.value, at_special_from_date_default.value) IS NULL AND at_special_price.value>0),at_special_price.value,IF(at_sellingprice.value>0,at_sellingprice.value,at_price.value))) as l_price')->group('product_name');
Run Code Online (Sandbox Code Playgroud)
我发现最低的销售价格,特价,经销商的mrp.
使用Group按产品名称对所有数据进行分组,获得最低价格的MINIMUM,按照LOWEST Price分类.
问题
正如我解释的那样,我正在使用GROUP …