我必须对Magento中的目录页面(list.phtml)进行一些更改,除了"排序依据"名称,位置等外,一切都很好......
这是我的代码:
$_productCollection= Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('*')
->addStoreFilter()
->setPage(Mage::getBlockSingleton('page/html_pager')->getCurrentPage(), $limit)
->setPageSize( $limit )
->setOrder($this->getCurrentOrder(), $this->getCurrentDirection())
->load();
Run Code Online (Sandbox Code Playgroud)
这里有一些错误,因为在尝试对名称,位置等结果进行排序时没有任何反应!
显然这条线有问题:
->setOrder($this->getCurrentOrder(), $this->getCurrentDirection())
Run Code Online (Sandbox Code Playgroud)
我也遇到了设置为不单独显示的简单产品的问题!我也错过了那里的东西.
如果有人能引导我走向正确的功能/语法,那就太好了!
我解决了订购问题!
- > setOrder(Mage :: getBlockSingleton('catalog/product_list_toolbar') - > getCurrentOrder(),Mage :: getBlockSingleton('catalog/product_list_toolbar') - > getCurrentDirection())
并且产品设置为不单独显示:
->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds())
Run Code Online (Sandbox Code Playgroud)
所以其他人的完整代码:
if( $this->getMode()!='grid' ) {
$limit = Mage::getStoreConfig('catalog/frontend/list_per_page');
}
else {
$limit = Mage::getStoreConfig('catalog/frontend/grid_per_page');
}
$_productCollection= Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
->addAttributeToSelect('sku_base')
->addStoreFilter(Mage::app()->getStore()->getId())
->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds())
->setPage(Mage::getBlockSingleton('page/html_pager')->getCurrentPage(), $limit)
->setPageSize( $limit )
->setOrder(Mage::getBlockSingleton('catalog/product_list_toolbar')->getCurrentOrder(), Mage::getBlockSingleton('catalog/product_list_toolbar')->getCurrentDirection())
->load();
Run Code Online (Sandbox Code Playgroud)