我试图修改我的list.phtml以仅显示简单和可配置产品。我不想要可配置产品(我不能因为其他原因而关闭可见性)
我改变了:
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>
要:
<?php
$_productCollection=$this->getLoadedProductCollection();
$_productCollection = clone $this->getLoadedProductCollection();
$_productCollection->clear()
->addAttributeToFilter(
array(
array('attribute'=>'type_id', 'eq'=>'simple'),
array('attribute'=>'type_id', 'eq'=>'grouped')
),
'',
'left'
)
->load();
$_helper = $this->helper('catalog/output');
?>
但我得到了这个错误:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'e.type_id' in 'where clause'
#0 /var/www/sync/store/loja/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/sync/store/loja/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /var/www/sync/store/loja/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /var/www/sync/store/loja/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT FLOOR((R...', Array)
#4 /var/www/sync/store/loja/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SELECT FLOOR((R...', Array)
#5 /var/www/sync/store/loja/lib/Zend/Db/Adapter/Abstract.php(808): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 /var/www/sync/store/loja/app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php(274): Zend_Db_Adapter_Abstract->fetchPairs(Object(Varien_Db_Select))
#7 /var/www/sync/store/loja/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php(158): Mage_Catalog_Model_Resource_Layer_Filter_Price->getCount(Object(MageWorx_SeoSuite_Model_Catalog_Layer_Filter_Price), 100)
#8 /var/www/sync/store/loja/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php(115): Mage_Catalog_Model_Layer_Filter_Price->getRangeItemCounts(100)
#9 /var/www/sync/store/loja/app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php(314): Mage_Catalog_Model_Layer_Filter_Price->getPriceRange()
#10 /var/www/sync/store/loja/app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php(151): Mage_Catalog_Model_Layer_Filter_Price->_getItemsData()
#11 /var/www/sync/store/loja/app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php(120): Mage_Catalog_Model_Layer_Filter_Abstract->_initItems()
#12 /var/www/sync/store/loja/app/code/core/Mage/Catalog/Model/Layer/Filter/Abstract.php(109): Mage_Catalog_Model_Layer_Filter_Abstract->getItems()
#13 /var/www/sync/store/loja/app/code/core/Mage/Catalog/Block/Layer/Filter/Abstract.php(132): Mage_Catalog_Model_Layer_Filter_Abstract->getItemsCount()
#14 /var/www/sync/store/loja/app/design/frontend/store/default/template/catalog/layer/view.phtml(55): Mage_Catalog_Block_Layer_Filter_Abstract->getItemsCount()
#15 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/sync/c...')
#16 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/store...')
#17 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#18 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml()
#19 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#20 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Text_List->_toHtml()
#21 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml()
#22 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('left', true)
#23 /var/www/sync/store/loja/app/design/frontend/store/default/template/page/2columns-left.phtml(52): Mage_Core_Block_Abstract->getChildHtml('left')
#24 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/sync/c...')
#25 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/store...')
#26 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#27 /var/www/sync/store/loja/app/code/local/MageWorx/SeoSuite/Block/Page/Html.php(36): Mage_Core_Block_Template->_toHtml()
#28 /var/www/sync/store/loja/app/code/core/Mage/Core/Block/Abstract.php(863): MageWorx_SeoSuite_Block_Page_Html->_toHtml()
#29 /var/www/sync/store/loja/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#30 /var/www/sync/store/loja/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#31 /var/www/sync/store/loja/app/code/core/Mage/Catalog/controllers/CategoryController.php(159): Mage_Core_Controller_Varien_Action->renderLayout()
#32 /var/www/sync/store/loja/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Catalog_CategoryController->viewAction()
#33 /var/www/sync/store/loja/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view')
#34 /var/www/sync/store/loja/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#35 /var/www/sync/store/loja/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#36 /var/www/sync/store/loja/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#37 /var/www/sync/store/loja/index.php(91): Mage::run('', 'store')
#38 {main}
有人知道我怎么能得到它?
答案 0 :(得分:0)
使用entity_type_id而不是type_id。但该集合需要一些其他过滤器,如类别,状态和其他过滤属性。我建议不要清除装载的产品集合。尝试重载产生该集合的产品列表助手,然后添加过滤器以仅列出简单且可配置的产品。
答案 1 :(得分:0)
$_products = Mage::getModel("catalog/product")->getCollection()
->addAttributeToFilter("type_id",array("eq"=>"simple"))
->addAttributeToFilter("type_id",array("eq"=>"grouped"));
试试这个
答案 2 :(得分:0)
尝试将addAttributeToFilter
替换为addFieldToFilter
,因为type_id是同一个表的一部分。