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

Error on Interceptor::addSortFilterParameters() in /var/ /Plugin/LayerPlugin.php:78 #330

Closed
anethum opened this issue Feb 10, 2017 · 33 comments
Assignees
Labels

Comments

@anethum
Copy link

anethum commented Feb 10, 2017

Hello,

if I enable this module I get a 500 error on the frontend with following error message

Fatal error: Uncaught Error: Call to undefined method Magento\Catalog\Model\ResourceModel\Product\Collection\Interceptor::addSortFilterParameters() in /var/www/xxx/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php:78 Stack trace: #0 /var/www/xxx/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php(59): Smile\ElasticsuiteCatalog\Plugin\LayerPlugin->setSortParams(Object(Magento\Catalog\Model\Layer\Category\Interceptor), Object(Magento\Catalog\Model\ResourceModel\Product\Collection\Interceptor)) #1 /var/www/xxx/htdocs/vendor/magento/framework/Interception/Interceptor.php(123): Smile\ElasticsuiteCatalog\Plugin\LayerPlugin->beforePrepareProductCollection(Object(Magento\Catalog\Model\Layer\Category\Interceptor), Object(Magento\Catalog\Model\ResourceModel\Product\Collection\Interceptor)) #2 /var/www/virtual/xxx/var/generation/Magento/Catalog/Model/Layer/Category/Interceptor.php(52): Magento\ in /var/www/xxx/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php on line 78

Following Versions are used:

elasticsuite 2.3.0 and 2.3.1
magento 2.1.3
php 7

@cizgidekiadam
Copy link

cizgidekiadam commented Feb 11, 2017

Same in here.

Magento 2.1.2 & 2.1.4
PHP 7.0.14
ElasticSuite 2.3.1 and 2.4.-dev

@afoucret
Copy link
Contributor

Hi,

Most of times, this kind of error occured when using both ElasticSuite and a module modifying the layout of the faceting together.
Custom themes may also not reflect the specific layout of ElasticSuite especially concerning the layered navigation.

Any modules / custom themes in your install ?

@cizgidekiadam
Copy link

Sure there is custom theme and layout like other many implementations.
How can i find which layout affected? For our situation, error thrown in product view page.
There is not any sort actions because it is just product. Sow why it tries addSortFilterParams?

@anethum
Copy link
Author

anethum commented Feb 13, 2017

yes, I also use a custom theme. But that a usual way, most shop's have own custom themes.

In my case this error thrown direct on the first /index.php page.

@romainruaud
Copy link
Collaborator

This error is due to the fact that the Product Collection getting catched by the Interceptor is not an "ElasticSuite Product Collection".

This can be due to several causes :

  • the configuration is not set properly to use ElasticSuite as search engine. You can verify that the following parameter is correctly set : Stores > Configuration > Catalog > Catalog Search > Search Engine.

  • a third party module may cause troubles by overriding the Catalog Product Collection. Please try to deactivate any third party module to find which one is causing trouble. You should look for references to \Magento\Catalog\Model\ResourceModel\Product\Collection or Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection in the di.xml files to see who is replacing this one.

You can also check what you are getting by calling get_class on the collection on the line just before the error occurs, to help identify which module is overriding the collection.

Best regards,

@anethum
Copy link
Author

anethum commented Feb 18, 2017

I check today the settings.

  • ElasticSuite is configured as search Engine.
  • I don't find any overriding modules as mentioned. Please look at the attachment di.zip

This failure occures only on the main page (index.php), not in the category, search or product page.

If this extension is activated, the search box is also away.

image

After deactivating, the search box is enabled.

image

.

@cizgidekiadam
Copy link

@romainruaud thanks for information.

But there is not any overrides on collection classes except ElasticSuite and search engine is set as ElasticSuite.

fyi

@romainruaud
Copy link
Collaborator

Hello @rbostan and @anethum , could you please attach the full stack trace of the error you have ? Could you also please name the custom theme you use (if they are community themes)

@anethum
Copy link
Author

anethum commented Feb 20, 2017

Please look at first Message, that's the full stack trace.

I use one of the most sold Magento Themes in Themeforest. Called Ultimo https://goo.gl/oNYW60

@romainruaud
Copy link
Collaborator

Hello @anethum , sorry but what you did post is not the full stack trace, just the error message. Please ask your development team to obtain the full stack trace which should figure all PHP calls that occured before reaching the erroneous statement.

Regarding the Ultimo theme, it is well known that this module does bad things on the layout and makes the search box disappear as spoken in #272

Could you also attached the complete list of third party extensions you are using ?

Regards

@romainruaud romainruaud self-assigned this Feb 24, 2017
@romainruaud
Copy link
Collaborator

romainruaud commented Feb 24, 2017

@anethum @rbostan I am able to reproduce this one on a category page.

This occurs if I am browsing a category which is set to have is_anchor=0.

All categories should have the is_anchor attribute set to 1. This is a prerequisite for the module to behave correctly, that's why the default value of this attribute is set to 1 during setup :

https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-catalog/Setup/InstallData.php#L135

But for sure, this piece of code does not have any effect on all categories created after the module install.

Can you please try to switch your categories to is_anchor=1 and see if the problem happens again ?

Best regards

@southerncomputer
Copy link
Contributor

Maybe due to the number of issues a status page which summarizes or aggregates data such as website_id , is_anchor values, attributes stats could be generated during each index - it would help expose the little quirks like this a lot faster! I mentioned is_anchor=1 in october 2016 causing this same error!

@romainruaud
Copy link
Collaborator

Hello @southerncomputer , I noticed that you encountered same issue in #170 but I did not see that you mentioned it was due to the is_anchor value :(

Sorry about that, we would have gain much time troubleshooting this issue...

We will provide a FAQ containing the most encountered issues or behavior to help people troubleshooting. But that's right, we may think about a warning on is_anchor values and also add it more clearly to the documentation.

Best regards and thank you again for the help you provide to other users here.

@anethum
Copy link
Author

anethum commented Feb 25, 2017

Hello,
on each category the anchor is set.

the failure occures only on the start page of the shop. Not on product or category view.

no error logs are recorded in the log files.

following modules are installed:

List of enabled modules:
Magento_Store
Magento_Directory
Infortis_Infortis
Infortis_Brands
Infortis_Cgen
Infortis_Dataporter
Infortis_Base
Magento_Eav
Infortis_UltraSlideshow
Magento_Theme
Magenerds_GermanLaw
Magento_Backend
Magento_AdvancedPricingImportExport
Magento_Authorization
Magento_Customer
Magento_Config
Magento_Backup
Magento_AdminNotification
Magento_Indexer
Magento_BundleImportExport
Magento_CacheInvalidate
Magento_Cms
Magento_Catalog
Magento_CatalogImportExport
Magento_Quote
Magento_Rule
Magento_Msrp
Magento_Search
Magento_CatalogUrlRewrite
Magento_Widget
Magento_SalesSequence
Magento_CheckoutAgreements
Magento_LayeredNavigation
Magento_CmsUrlRewrite
Magento_RequireJs
Magento_ConfigurableImportExport
Magento_Payment
Magento_Contact
Magento_Cookie
Magento_Cron
Magento_CurrencySymbol
Infortis_UltraMegamenu
Magento_CustomerImportExport
Magento_Deploy
Magento_Developer
Magento_Dhl
Magento_CatalogInventory
Magento_Downloadable
Magento_ImportExport
Magento_Sales
Magento_Email
Magento_User
Magento_Fedex
Magento_GiftMessage
Magento_Checkout
Magento_GoogleAnalytics
Magento_Ui
Magento_GroupedImportExport
Magento_GroupedProduct
Magento_DownloadableImportExport
Magento_Bundle
Magento_Security
Infortis_Ultimo
Magento_Marketplace
Magento_MediaStorage
Magento_CatalogRule
Magento_Multishipping
Magento_ConfigurableProduct
Magento_Newsletter
Magento_OfflinePayments
Magento_SalesRule
Magento_PageCache
Magento_Authorizenet
Magento_Vault
Magento_Persistent
Magento_ProductAlert
Magento_ProductVideo
Magento_Paypal
Magento_Reports
Magento_Shipping
Magento_Review
Magento_Rss
Magento_CatalogRuleConfigurable
Magento_NewRelicReporting
Magento_SalesInventory
Magento_OfflineShipping
Magento_Captcha
Magento_SampleData
Magento_CatalogSearch
Magento_Integration
Magento_SendFriend
Magento_Tax
Magento_Sitemap
Henhed_Piwik
Magento_Swagger
Magento_Swatches
Magento_SwatchesLayeredNavigation
Ess_M2ePro
Magento_TaxImportExport
Magento_GoogleAdwords
Magento_Translation
Magento_GoogleOptimizer
Magento_Ups
Magento_UrlRewrite
Magento_EncryptionKey
Magento_Usps
Magento_Variable
Magento_Braintree
Magento_Version
Magento_Webapi
Magento_WebapiSecurity
Magento_Weee
Magento_CatalogWidget
Magento_Wishlist

List of disabled modules:
Smile_ElasticsuiteCore
Smile_ElasticsuiteCatalog
Smile_ElasticsuiteCatalogRule
Smile_ElasticsuiteCatalogOptimizer
Smile_ElasticsuiteSwatches
Smile_ElasticsuiteThesaurus
Smile_ElasticsuiteTracker
Smile_ElasticsuiteVirtualCategory

@afoucret
Copy link
Contributor

Hi @anethum,

Our module does not have any side effects on the homepage.
I would bet that an one of the Infortis module is loading a layer on the homepage. Try to disable the modules one by one to see what happen ...

@cizgidekiadam
Copy link

@afoucret @romainruaud
Our all categories are is_anchor=1 and problem still exists.
Reminding, this error occurs in product detail (view) page.

If I commented elasticsuite-catalog/Plugin/LayerPlugin.php:78
/*$collection->addSortFilterParameters('position', 'category.position', 'category', ['category.category_id' => $categoryId]);*/ error gone.

I suspect that this issue may be related (or source of) with #344

Fyi

@romainruaud
Copy link
Collaborator

romainruaud commented Mar 15, 2017

Hello @rbostan

please attach the complete stacktrace of the error.

I have took a look on Infortis theme and saw many bad things especially one in the Block/Product/ProductList/Featured.php

I am amble to reproduce your error if I put this block on my homepage (or anywhere else).

On this block, they do this dirty thing :

 $collection = $category->getProductCollection();
....

$this->_categoryLayerFactory
        ->create()
        ->prepareProductCollection($collection);

This should rather be :

$collection = $this->_categoryLayerFactory
    ->create()
    ->setCurrentCategory($category)
    ->getProductCollection(); // The getProductCollection method calls the prepareProductCollection() internally

Doing this fix the error by my side.

Feel free to communicate this quickfix to them if you want,

Best regards,

@cizgidekiadam
Copy link

Exactly same trace as @anethum's

Fatal error: Uncaught Error: Call to undefined method Magento\Catalog\Model\ResourceModel\Product\Collection\Interceptor::addSortFilterParameters() in /home/domain/public_html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php:78 
Stack trace: 
#0 /home/domain/public_html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php(59): Smile\ElasticsuiteCatalog\Plugin\LayerPlugin->setSortParams(Object(Magento\Catalog\Model\Layer\Category\Interceptor), Object(Magento\Catalog\Model\ResourceModel\Product\Collection\Interceptor)) 
#1 /home/domain/public_html/vendor/magento/framework/Interception/Interceptor.php(123): Smile\ElasticsuiteCatalog\Plugin\LayerPlugin->beforePrepareProductCollection(Object(Magento\Catalog\Model\Layer\Category\Interceptor), Object(Magento\Catalog\Model\ResourceModel\Product\Collection\Interceptor)) 
#2 /home/domain/public_html/var/generation/Magento/Catalog/Model/Layer/Category/Interceptor.php(26): Magento\Catalog\Model\Layer\Category\Interceptor in /home/domain/public_html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php on line 78

@romainruaud
Copy link
Collaborator

Hello,

the stack trace you give is incomplete, you should have many more calls occuring before passing on the Category/Interceptor one.

Did you try to check the point I indicated on your Infortis module also ?

regards

@cizgidekiadam
Copy link

I'm not using Infortis. That is anethum's module list 😃
This occurs only product view page which is not requires sorting etc.

Default sort (sort by position) is broken in category pages. I could't get correct order. But you said it is not related with this module in #344
(Still i have doubts with this 😉, investigating)

Home page working well.

@romainruaud
Copy link
Collaborator

@rbostan then you have something which is instantiating a layer and using it wrongly on the product view page.

Could you please post the list of all third party modules you are using ? And also check what is added in your product detail page which is not here on a standard M2 luma theme.

Also please check for calls to "prepareProductCollection" which could be processed in third party modules or custom code.

And please, attach the complete stack trace of the error you are having, not only the first 2 rows.

Best regards,

@romainruaud
Copy link
Collaborator

The issues which were due to a mis-usage of Layer have been fixed in latest 2.3.3 release.

I close this issue, feel free to open a new one if you are still facing problems.

Best regards,

@tanolalano
Copy link

Hi all,
@romainruaud follow your suggestion in FAQ about
Fatal error: Uncaught Error: Call to undefined method Magento\Catalog\Model\ResourceModel\Product\Collection\Interceptor::addSortFilterParameters() in /var/www/xxx/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php:56
on Infortis/ultimo theme.
I replace the code you suggested on (as in FAQ) in:
/app/code/Infortis/Base/Block/Product/ProductList/Featured.php
I get no image for products and wrong category products (maybe get random products).
If I comment out line 56 an 78 of LayerPlugin.php without any modification of Featured.php all is works perfect.
Seems I have same issue @rbostan
PS using Elasticsuite 2.3.3 on Magento 2 - php 7.0.18
Best Regards

@roman204
Copy link

roman204 commented Nov 21, 2017

but to show products only from the given category you should add a categoryFilter

$collection = $this->_categoryLayerFactory
                    ->create()
                    ->getProductCollection();
                $collection->addCategoryFilter($category);

@markdimi
Copy link

markdimi commented Jul 6, 2018

We are using Infortis Ultimo and would love to use elasticsuite. Sadly they didn't provide any fixes. Could I maybe fix their issue somehow? Would that be a viable solution?

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Jun 30, 2020

Same problem on WeltPixel Pearl theme.

Fatal error: Uncaught Error: Call to undefined method WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor::addSortFilterParameters() in /var/www/html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php:87
Stack trace:
#0 /var/www/html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php(67):
 Smile\ElasticsuiteCatalog\Plugin\LayerPlugin->setSortParams(Object(Magento\Catalog\Model\Layer\Category\Interceptor), Object(WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor))
 #1 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(121): Smile\ElasticsuiteCatalog\Plugin\LayerPlugin->beforePrepareProductCollection(Object(Magento\Catalog\Model\Layer\Category\Interceptor), Object(WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor)) #2 /var/www/html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\Layer\Category\Interceptor->Magento\Framework\Interc in /var/www/html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php on line 87

@LiamKarlMitchell
Copy link

If a third party module is over-riding the Magento FullText to its own e.g.
WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor

Can we edit it to over-ride a Smile-SA/elasticsuite FullText module? Would that fix it?

@Ashish11
Copy link

Ashish11 commented Jul 2, 2020

@LiamKarlMitchell , are you able to fix WeltPixel\LayeredNavigation issue? I am also facing the same one, my error is
Fatal error: Uncaught Error: Call to undefined method WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor::addSortFilterParameters() in /srv/public_html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php:87 Stack trace: #0 /srv/public_html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php(67): Smile\ElasticsuiteCatalog\Plugin\LayerPlugin->setSortParams(Object(Magento\Catalog\Model\Layer\Category\Interceptor), Object(WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor)) #1 /srv/public_html/vendor/magento/framework/Interception/Interceptor.php(121): Smile\ElasticsuiteCatalog\Plugin\LayerPlugin->beforePrepareProductCollection(Object(Magento\Catalog\Model\Layer\Category\Interceptor), Object(WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor)) #2 /srv/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Model\Layer\Category\Interceptor->Magento\Fram in /srv/public_html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php on line 87

@KaushikChavda
Copy link

@Ashish11 ,

Have you fixed this issue with the WeltPixel theme? I'm having the same issue.

@pranayKdev11
Copy link

Does Anybody Had solutions for these issue. I had same kind of error. Please anybody had solved can answer.

Fatal error: Uncaught Error: Call to undefined method WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor::addSortFilterParameters() in /srv/public_html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php:87

@LiamKarlMitchell
Copy link

Sorry I don't recall how we sorted it, might have disabled weltpixels layered navigation or contacted welt pixel support for a fix?

@pranayKdev11
Copy link

@LiamKarlMitchell Thanks for Response.
As per your Update, I will look into It.

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Feb 4, 2022

@pranayKdev11 Looked up the error in our ticket system to see what we did.

WeltPixel_LayeredNavigation and Search seem to be incompatible with Smile ElasticSearch.
Searching autocomplete (whilst typing) gives me this.

Fatal error: Uncaught Error: Call to undefined method WeltPixel\LayeredNavigation\Model\ResourceModel\Fulltext\Collection\Interceptor::addSortFilterParameters() in /var/www/html/vendor/smile/elasticsuite/src/module-elasticsuite-catalog/Plugin/LayerPlugin.php:87

You need to disable these modules to use Smile-SA Elastic Search with WeltPixel theme.
WeltPixel_AdvanceCategorySorting
WeltPixel_LayeredNavigation
WeltPixel_SearchAutoComplete

Note: Still have issue with autocomplete type-ahead search options not being clickable but they do show up now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests