Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Magento\CatalogSearch\Model\Query::getResultCollection() not working #565

Closed
wants to merge 1 commit into from

Conversation

jason-neumann
Copy link

When searching for products using the CatalogSearch module, if the site is setup in a single store configuration, calling getResultCollection() was returning no results for me. This is the query it was using:

SELECT 
    `e` . *,
    `price_index`.`price`,
    `price_index`.`tax_class_id`,
    `price_index`.`final_price`,
    IF(price_index.tier_price IS NOT NULL,
        LEAST(price_index.min_price,
                price_index.tier_price),
        price_index.min_price) AS `minimal_price`,
    `price_index`.`min_price`,
    `price_index`.`max_price`,
    `price_index`.`tier_price`
FROM
    `catalog_product_entity` AS `e`
        INNER JOIN
    `catalog_product_website` AS `product_website` ON product_website.product_id = e.entity_id
        AND product_website.website_id = '1'
        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
WHERE
    (`e`.`entity_id` IN (SELECT 
            `t1`.`entity_id`
        FROM
            `catalog_product_entity_varchar` AS `t1`
                LEFT JOIN
            `catalog_product_entity_varchar` AS `t2` ON t1.entity_id = t2.entity_id
                AND t1.attribute_id = t2.attribute_id
                AND t2.store_id = 1
        WHERE
            (t1.attribute_id IN ('71'))
                AND (t1.store_id = 0)
                AND (IF(t2.value_id > 0, t2.value, t1.value) LIKE '%balloon%')));

The last line of the query was failing. Since t2 is joined with the condition "AND store_id = 1" and no rows in catalog_product_entity_varchar have store_id=1, the value of t2.value_id is NULL. The results of NULL > 0 is UNKNOWN. This caused the query to return no results. Changing the code to IFNULL(t2.value, t1.value) made it work for me.

@verklov verklov self-assigned this May 5, 2014
@verklov
Copy link
Contributor

verklov commented May 5, 2014

@jason-neumann, thank you for your contribution! We have created the ticket in the product backlog. We will get back to you once the team finishes the analysis.

magento-team added a commit that referenced this pull request Jun 16, 2014
* Added support for MTF Reporting Tool
* Framework improvements:
  * Covered the following Magento application components with unit tests:
      * `ConfigurableProduct/Helper/Data.php`
      * `ConfigurableProduct/Model/Export/RowCustomizer.php`
      * `ConfigurableProduct/Model/Product/Type/Configurable.php`
      * `ConfigurableProduct/Model/Product/Type/Plugin.php`
      * `ConfigurableProduct/Model/Quote/Item/QuantityValidator/Initializer/Option/Plugin/ConfigurableProduct.php`
      * `CatalogSearch/Helper/Data.php`
  * Covered Magento lib with unit tests:
      * `lib/internal/Magento/Framework/DB/Helper/AbstractHelper.php`
      * `lib/internal/Magento/Framework/DB/Tree/Node.php`
* Created Service API for Magento_Catalog Module:
  * Implemented the Product API
  * Implemented the ProductAttributeRead API
* Fixed bugs:
  * Fixed issues with form elements visibility on the backend
  * Fixed an issue where backend forms contained an excessive container
  * Fixed an issue where a wrong category structure was displayed on the Category page
  * Fixed an issue where the pub/index.php entry point was broken because of the obsolete constants
  * Fixed an issue where it was impossible to pass an empty array as an argument in DI configuration and layout updates
  * Fixed an issue with status and visibility settings of a related product on the backend
  * Fixed an issue with unused DB indexes, which used resources, but did not contribute to higher performance
  * Fixed an issue where it was possible to create a downloadable product without specifying a link or a file
  * Fixed an issue where a fatal error occured when opening a fixed bundle product with custom options page on the frontend
  * Fixed an issue where the was a wrong config key for backend cataloginventory
* Processed GitHub requests:
  * [#548] (#548) -- Console installer doesn't checks filesystem permissions
  * [#552] (#552) -- backend notifications sitebuild bug
  * [#562] (#562) -- Bugfix Magento\Framework\DB\Adapter\Pdo\Mysql::getCreateTable()
  * [#565] (#565) -- Magento\CatalogSearch\Model\Query::getResultCollection() not working
  * [#557] (#557) -- translation anomalies backend login page
* Added the following functional tests:
  * Advanced Search
  * Existing Customer Creation
  * Product Attribute Creation
  * Product Rating Creation
  * Sales Rule Creation
  * System Product Attribute Deletion
  * Tax Rate Creation
  * Tax Rule Deletion
  * Update Category
  * Update Category Url Rewrite
  * Update Product Url Rewrite
@verklov
Copy link
Contributor

verklov commented Jun 26, 2014

@jason-neumann, the team processed your code contribution and deployed the code in version dev82. Thank you for helping us make Magento better!

@verklov verklov closed this Jun 26, 2014
joanhe pushed a commit that referenced this pull request Oct 21, 2015
…hant-beta

[Extensibility] MAGETWO-41996: [GitHub] DI compilation fails on class keyword #1722, MAGETWO-41792: Multiple stores at different paths rendering wrong store base_url
magento-team pushed a commit that referenced this pull request Apr 28, 2016
magento-devops-reposync-svc pushed a commit that referenced this pull request Dec 4, 2023
ACPT-1589: Add GraphQL P1 queries to GraphQlStateTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants