2

我试图修改我的 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}

有谁知道我怎样才能得到它?

4

3 回答 3

0

使用 entity_type_id 而不是 type_id。但是该集合需要一些其他过滤器,例如类别、状态和其他过滤属性。我建议不要清除加载的产品集合。尝试重载生成该集合的产品列表助手,然后添加您的过滤器以仅列出简单且可配置的产品。

于 2013-07-09T05:55:45.243 回答
0
$_products = Mage::getModel("catalog/product")->getCollection()
            ->addAttributeToFilter("type_id",array("eq"=>"simple"))
            ->addAttributeToFilter("type_id",array("eq"=>"grouped"));

试试这个

于 2013-07-09T07:09:00.360 回答
0

尝试替换addAttributeToFilter为,addFieldToFilter因为 type_id 是同一张表的一部分。

于 2016-07-06T11:16:48.103 回答