Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. SELECT * FROM catalog_category_entity AS catalog_category_table
  2. LEFT JOIN (SELECT DISTINCT(product_id),category_id FROM catalog_category_product GROUP BY product_id) catalog_category_product_table ON catalog_category_product_table.category_id = catalog_category_table.entity_id
  3.  
  4. $subquery = new Zend_Db_Expr("(
  5. SELECT DISTINCT(product_id), category_id
  6. FROM `catalog_category_product`
  7. GROUP BY product_id
  8. )");
  9. $collection = Mage::getModel('catalog/category')->getCollection();
  10. $collection->getSelect()
  11. ->joinLeft(
  12. $subquery,
  13. 't.category_id = e.entity_id'
  14. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement