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

2.3.2 Upgrade Undefined factory elasticsuite #1445

Closed
NathMorgan opened this issue Jun 26, 2019 · 7 comments · Fixed by #1461
Closed

2.3.2 Upgrade Undefined factory elasticsuite #1445

NathMorgan opened this issue Jun 26, 2019 · 7 comments · Fixed by #1461
Assignees
Labels

Comments

@NathMorgan
Copy link

NathMorgan commented Jun 26, 2019

After removing or fixing the plugin in this issue: #1442 when trying to use the search it throws a exception with Undefined factory elasticsuite being thrown in this file: https://github.com/magento/magento2/blob/9fc254f241b5a2fa9e28ebdbb179538ca7c1959f/app/code/Magento/Elasticsearch/Model/Layer/Search/ItemCollectionProvider.php#L46

Preconditions

Magento Version : 2.3.2

ElasticSuite Version : 2.8.0

Environment : Developer

Third party modules : N/A

Steps to reproduce

  1. Using default Magento's search
  2. Search for a item

Expected result

  1. Search page should load with products related to the search

Actual result

  1. Exception is thown `Undefined factory elasticsuite

From checking it seems this file is newly added in 2.3.2

@Quazz
Copy link

Quazz commented Jun 26, 2019

Looks like you have to do something similar to magento/magento2@885b7a9#diff-b2e0d454e4ffd542fa96dc1b7dc225d9 this now, though I haven't gotten that to work personally

@southerncomputer
Copy link
Contributor

southerncomputer commented Jun 26, 2019

worked for me after dealing with the broken addisinstockfilter plugin:

in elasticsuitecatalog\etc\di.xml add :

<virtualType name="elasticsearchLayerCategoryItemCollectionProvider" type="Magento\Elasticsearch\Model\Layer\Category\ItemCollectionProvider">
        <arguments>
            <argument name="factories" xsi:type="array">
                <item name="elasticsuite" xsi:type="object">Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\CollectionFactory</item>
            </argument>
        </arguments>
    </virtualType>

    <type name="Magento\CatalogSearch\Model\Search\ItemCollectionProvider">
        <arguments>
            <argument name="factories" xsi:type="array">
                <item name="elasticsuite" xsi:type="object">elasticsearchAdvancedCollectionFactory</item>
            </argument>
        </arguments>
    </type>

    <type name="Magento\CatalogSearch\Model\Advanced\ProductCollectionPrepareStrategyProvider">
        <arguments>
            <argument name="strategies" xsi:type="array">
                <item name="elasticsuite" xsi:type="object">Magento\Elasticsearch\Model\Advanced\ProductCollectionPrepareStrategy</item>
            </argument>
        </arguments>
    </type>

    <virtualType name="elasticsearchLayerSearchItemCollectionProvider" type="Magento\Elasticsearch\Model\Layer\Search\ItemCollectionProvider">
        <arguments>
            <argument name="factories" xsi:type="array">
                <item name="elasticsuite" xsi:type="object">Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\CollectionFactory</item>
            </argument>
        </arguments>
    </virtualType>

@southerncomputer
Copy link
Contributor

Also you could put back the module-catalog-inventory/Model/Plugin/Layer.php instead of deleting this plugin in elasticsearch:

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\CatalogInventory\Model\Plugin;

class Layer
{
    /**
     * Stock status instance
     *
     * @var \Magento\CatalogInventory\Helper\Stock
     */
    protected $stockHelper;

    /**
     * Store config instance
     *
     * @var \Magento\Framework\App\Config\ScopeConfigInterface
     */
    protected $scopeConfig;

    /**
     * @param \Magento\CatalogInventory\Helper\Stock $stockHelper
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
     */
    public function __construct(
        \Magento\CatalogInventory\Helper\Stock $stockHelper,
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
    ) {
        $this->stockHelper = $stockHelper;
        $this->scopeConfig = $scopeConfig;
    }

    /**
     * Before prepare product collection handler
     *
     * @param \Magento\Catalog\Model\Layer $subject
     * @param \Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection $collection
     *
     * @return void
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function beforePrepareProductCollection(
        \Magento\Catalog\Model\Layer $subject,
        \Magento\Catalog\Model\ResourceModel\Collection\AbstractCollection $collection
    ) {
        if ($this->_isEnabledShowOutOfStock()) {
            return;
        }
        $this->stockHelper->addIsInStockFilterToCollection($collection);
    }

    /**
     * Get config value for 'display out of stock' option
     *
     * @return bool
     */
    protected function _isEnabledShowOutOfStock()
    {
        return $this->scopeConfig->isSetFlag(
            'cataloginventory/options/show_out_of_stock',
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        );
    }
}

@torstenfreyda
Copy link

worked for me after dealing with the broken addisinstockfilter plugin:

in elasticsuitecatalog\etc\di.xml add :

<virtualType> name="elasticsearchLayerCategoryItemCollectionProvider" type="Magento\Elasticsearch\Model\Layer\Category\ItemCollectionProvider">
        <arguments>
            <argument name="factories" xsi:type="array">
                <item name="elasticsuite" xsi:type="object">Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\CollectionFactory</item>
            </argument>
        </arguments>
    </virtualType>

    <type name="Magento\CatalogSearch\Model\Search\ItemCollectionProvider">
        <arguments>
            <argument name="factories" xsi:type="array">
                <item name="elasticsuite" xsi:type="object">elasticsearchAdvancedCollectionFactory</item>
            </argument>
        </arguments>
    </type>

    <type name="Magento\CatalogSearch\Model\Advanced\ProductCollectionPrepareStrategyProvider">
        <arguments>
            <argument name="strategies" xsi:type="array">
                <item name="elasticsuite" xsi:type="object">Magento\Elasticsearch\Model\Advanced\ProductCollectionPrepareStrategy</item>
            </argument>
        </arguments>
    </type>

    <virtualType name="elasticsearchLayerSearchItemCollectionProvider" type="Magento\Elasticsearch\Model\Layer\Search\ItemCollectionProvider">
        <arguments>
            <argument name="factories" xsi:type="array">
                <item name="elasticsuite" xsi:type="object">Smile\ElasticsuiteCatalog\Model\ResourceModel\Product\Fulltext\CollectionFactory</item>
            </argument>
        </arguments>
    </virtualType>

Thank you, for that post. That saved my day. Mind the first tag and remove the ">" after virtualType <virtualType> name....

@romainruaud
Copy link
Collaborator

Hello people,

we are working on this one and aim to release an ElasticSuite 2.8.1 version as soon as possible :)

@androshchuk will have a look on this one.

I'm not sure "just" adding the factories will work properly. Maybe we'll also have to implement them, I'm not sure since I did not dig more into this.

@nuzil
Copy link

nuzil commented Jul 6, 2019

This one is fixed issue for me. https://github.com/comwrap/elasticsuite-magento-patch

Hope will help somebody. If there are any problems please report or you can also push PR there

@romainruaud
Copy link
Collaborator

Fixed by PR #1461

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

Successfully merging a pull request may close this issue.

7 participants