Some of the products weren't showing up in the search results on a site that I've been working on.

After looking at it for a while and logging the sql queries I've found that it's only searching the default category (category_id = 2). The first query is:

SELECT `s`.`product_id`, 0 AS `relevance` 
FROM `catalogsearch_fulltext` AS `s`
INNER JOIN `catalog_product_entity` AS `e` 
ON e.entity_id = s.product_id 
WHERE (s.store_id = 1) AND ((`s`.`data_index` LIKE '%denim%'))

which has 26 results, the next query is:

FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_product_index_price` AS `price_index` 
ON price_index.entity_id = e.entity_id 
  AND price_index.website_id = '1' 
  AND price_index.customer_group_id = 0
INNER JOIN `catalog_category_product_index` AS `cat_index` 
ON cat_index.product_id=e.entity_id 
  AND cat_index.store_id='1' 
  AND cat_index.visibility IN(3, 4) 
  AND cat_index.category_id = '2'
WHERE (`e`.`entity_id` IN(<the previous product_ids>))

since the products aren't in the default category they aren't showing up. My question is how to change this so it searches all queries.

1 Answer 1


First to check your all products number use this:

echo $collection = Mage::getModel('catalog/product')->getCollection()->getSize();

Then use this collection to get the collection of your all products:

$collection = Mage::getModel('catalog/product')->getCollection()
                            ->addAttributeToSelect('*') // to get all attributes
                            ->setPageSize(5000) // to limit the results returned
                            ->setCurPage(1); // useful for pagination

        foreach ($collection as $product) {
          echo $product->getName().'<br />'; // some name
          echo $product->getId().'<br />'; // 1205 
          echo $product->getStatus().'<br />'; // 1 
          echo $product->getTypeId().'<br />'; // simple 

To get all categories without filters

$categories = Mage::getModel('catalog/category')->getCollection()
        foreach ($categories as $cat) {
              echo $cat->getName().'<br />'; // some name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.