-
-
Notifications
You must be signed in to change notification settings - Fork 437
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
Rewrote the $select->setPart() usage because it looses the "where type" #2660
Conversation
I think this shouldn’t be closed, it’s bad code what’s in use now |
Was closed by github/my PR... just reopen. |
What's "bad"? |
It should be explained the in pr description |
I like it, make me a reviewer and i approve it. |
I think you can review it anyway, it won't be a green check but it's still very valuable, 1 green mark and 2 gray it's 100 approved |
I tested this now but it doesn't resolve the problem completely, I get a stray SELECT FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 AS `range`, COUNT(*) AS `count`
FROM `catalog_product_index_price` AS `e`
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 (AND (e.entity_id IN(554, 442, 445, 441, 446, 398, 408, 409, 410))) AND ( e.website_id = '1' ) AND ( e.customer_group_id = 0) AND (e.min_price IS NOT NULL) GROUP BY FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 ORDER BY FLOOR((ROUND((e.min_price) * 1, 2)) / 100) + 1 ASC You need to have "Use In Search Results Layered Navigation" set to "Yes" for the |
isn't it possible that that problem comes from another site and it's not related to the modified method? cause, checking what i modified in this PR, it seems weird |
I guess i have to agree the ORM is to stupid so the dev choose to add the 1=1 before, so the AND does not become a problem. Need to work on this, I am going to check your solution in a customer project and report back. |
But if this happens due to ORM stupidity, and the reported error is continuous, why not just prepend 1=1 to the where part array in general. I check whats going on in the next few days. |
It actually makes sense, since |
I'll try to check it out ASAP, if you've ideas they're obviously more then welcome :-) |
@elidrissidev I can't reproduce the problem you see, can you help me here? |
In this part of code
magento-lts/app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php
Lines 118 to 128 in 15f83af
There's a weird hack (that 1=1 replacement) that doesn't look very nice but most of all the usage of the
$select->setPart(Zend_Db_Select::WHERE, $wherePart);
is wrong, I'll try to explain.When doing
$select->where("some condition")
you're actually callingmagento-lts/app/code/core/Zend/Db/Select.php
Lines 1031 to 1052 in 15f83af
With the current implementation this whole thing gets bypassed and the
$select->setPart(Zend_Db_Select::WHERE, $wherePart);
looses the where type, creating the problem described in #2658This PR rewrites that small part of code removing the 1=1 hack which becomes useless, the code is more correct and looks better IMHO.
Also, you can see in the same file modified by this PR, just a few lines below
magento-lts/app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php
Lines 129 to 136 in 15f83af