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

Allowed "force enabling" of flat tables use for a product collection #2954

Merged
merged 3 commits into from
May 14, 2023

Conversation

loekvangool
Copy link
Contributor

Fixes #2914

@github-actions github-actions bot added the Component: Catalog Relates to Mage_Catalog label Jan 16, 2023
@loekvangool
Copy link
Contributor Author

loekvangool commented Jan 16, 2023

Example on how to implement a fast flat table collection while in an area that until now blocks access to flat tables:

$productFlatHelper = Mage::helper('catalog/product_flat');
var_dump("<br>\$productFlatHelper->isFlatCollectionDisabled(): ".$productFlatHelper->isFlatCollectionDisabled()); // true if in cart
$productFlatHelper->enableFlatCollection(true); // call to the new method
var_dump("<br>\$productFlatHelper->isFlatCollectionDisabled(): ".$productFlatHelper->isFlatCollectionDisabled()); // false

// Get some products
$_products = Mage::getModel("catalog/product")->setPageSize(12)->setCurPage(1);
var_dump($collection->getSelect()->__toString()); // uses flat table

$productFlatHelper->resetFlatCollection();
var_dump("<br>\$productFlatHelper->isFlatCollectionDisabled(): ".$productFlatHelper->isFlatCollectionDisabled()); // back to true, not breaking anything

@elidrissidev
Copy link
Member

Can you add a space after the if to make PHP-CS-Fixer check pass.

@fballiano fballiano changed the base branch from 1.9.4.x to main May 13, 2023 14:48
@fballiano fballiano changed the base branch from main to 1.9.4.x May 13, 2023 14:48
@github-actions github-actions bot added Component: AdminNotification Relates to Mage_AdminNotification Component: Adminhtml Relates to Mage_Adminhtml Component: Admin Relates to Mage_Admin Component: Cm/RedisSession Relates to Cm_RedisSession ddev documentation environment htaccess Mage.php Relates to app/Mage.php php-cs-fixer phpcs phpstan PHPStorm phpunit and removed Component: Catalog Relates to Mage_Catalog labels May 13, 2023
@fballiano fballiano changed the base branch from 1.9.4.x to main May 13, 2023 14:53
@github-actions github-actions bot added Component: Catalog Relates to Mage_Catalog and removed PHPStorm phpcs Component: Adminhtml Relates to Mage_Adminhtml Component: Admin Relates to Mage_Admin Mage.php Relates to app/Mage.php htaccess labels May 13, 2023
Copy link
Contributor

@fballiano fballiano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not love this PR because of #2914 (comment) but, at the end of the day, it has to be forces by somebody in his/her own code so it's fine with me

@fballiano fballiano changed the title Allow enabling of flat tables for a product collection Allowed "force enabling" of flat tables use for a product collection May 14, 2023
@fballiano fballiano merged commit c925d26 into OpenMage:main May 14, 2023
@loekvangool loekvangool deleted the patch-5 branch July 3, 2023 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow flat tables in cart and checkout
4 participants