2013-04-25 172 views
0

在Magento中,我想通過腳本過濾沒有任何父產品的產品。 目前,我做這樣的事情:Magento PHP:沒有父母的產品

$products = $this->_productModel->getCollection() 
    ->addAttributeToSelect('*') 
    ->addStoreFilter($this->_storeId) 
    ->addAttributeToFilter('type_id',array('in'=>$_types)) 
    ->addAttributeToFilter('status',array('in'=>$_status)) 
    ->joinTable('cataloginventory/stock_item', 'product_id=entity_id', array('qty'=>'qty','is_in_stock' => 'is_in_stock'), $this->_getStockSQL(), 'inner'); 

我得到了所有的產品,但我可以說「給我的不僅是產品沒有父母」使用getCollection()?

感謝

回答

0

父產品和子產品僅在分組,配置,和捆綁產品可用的編緝。如果你不想讓父母產品

檢查id爲PARENT_ID在catalog_product_relation和catlog_product_super_link那麼它的父產品

0

完美:)

->joinTable('catalog_product_relation', "parent_id=entity_id",array('child_id'=>'child_id'), null, "inner") 

感謝

相關問題