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

Remove product load in helper #20

Open
milansimek opened this issue Feb 26, 2016 · 0 comments
Open

Remove product load in helper #20

milansimek opened this issue Feb 26, 2016 · 0 comments

Comments

@milansimek
Copy link

The following part contains a product load, which slows everything down:

https://github.com/fheyer/sphinxsearch/blob/master/app/code/community/Gfe/SphinxSearch/Helper/Data.php#L99

It's better to replace it with:

if ($entity_id)
            {
                $categoryCollection = Mage::getResourceModel('catalog/category_collection')
                    ->clear()
                    ->joinField('product_id',
                        'catalog/category_product',
                        'product_id',
                        'category_id = entity_id',
                        null)
                    ->addFieldToFilter('product_id', (int)$entity_id)
                    ->addNameToResult()
                ;
                    foreach ($categoryCollection as $item) {
                        $categories[] = $item->getName();
                    }
            }
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

No branches or pull requests

1 participant