且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从magento getCollection中排除类别

更新时间:2023-11-30 13:55:10

我认为这应该可行,前提是您知道要过滤的类别ID,但现在无法测试

I think this should work, presuming you know what category ID you want to filter out, but I can't test it right now

$catId = 9;

/* I'm almost positive 'e' is the alias used for catalog_product_entity, check your
   query with echo (string) $products->getSelect(); if it doesn't work */
$products->getSelect()->join(array('cats' => 'catalog_category_product'), 'cats.product_id = e.entity_id');
$products->getSelect()->where('cats.category_id', array('neq' => $catId));