src/module-elasticsuite-catalog-rule/etc/di.xml
<?xml version="1.0"?>
<!--
/**
* Smile_ElasticsuiteCatalogRule dependency injection configuration.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
* versions in the future.
*
* @category Smile
* @package Smile\ElasticsuiteCatalogRule
* @author Romain Ruaud <romain.ruaud@smile.fr>
* @copyright 2021 Smile
* @license Open Software License ("OSL") v. 3.0
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<!-- Add the default Elasticsuite Special Attributes. -->
<type name="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttributesProvider">
<arguments>
<argument name="attributes" xsi:type="array">
<item name="has_image" xsi:type="object">Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\HasImage</item>
<item name="stock.is_in_stock" xsi:type="object">Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\IsInStock</item>
<item name="price.is_discount" xsi:type="object">Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\IsDiscount</item>
<item name="is_bundle" xsi:type="object">isBundleProduct</item>
<item name="is_configurable" xsi:type="object">isConfigurableProduct</item>
<item name="is_downloadable" xsi:type="object">isDownloadableProduct</item>
<item name="is_giftcard" xsi:type="object">isGiftCardProduct</item>
<item name="is_grouped" xsi:type="object">isGroupedProduct</item>
<item name="is_simple" xsi:type="object">isSimpleProduct</item>
<item name="is_created_within_last_x_days" xsi:type="object">isCreatedWithinLastXdays</item>
<item name="is_updated_within_last_x_days" xsi:type="object">isUpdatedWithinLastXdays</item>
<item name="stock.qty" xsi:type="object">Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\StockQty</item>
</argument>
</arguments>
</type>
<!-- Add the Virtual Types for distinguish between product types -->
<virtualType name="isBundleProduct" type="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\ProductType">
<arguments>
<argument name="attributeCode" xsi:type="string">is_bundle</argument>
<argument name="typeIdentifier" xsi:type="string">bundle</argument>
<argument name="attributeLabel" xsi:type="string">Only bundle products</argument>
</arguments>
</virtualType>
<virtualType name="isConfigurableProduct" type="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\ProductType">
<arguments>
<argument name="attributeCode" xsi:type="string">is_configurable</argument>
<argument name="typeIdentifier" xsi:type="string">configurable</argument>
<argument name="attributeLabel" xsi:type="string">Only configurable products</argument>
</arguments>
</virtualType>
<virtualType name="isDownloadableProduct" type="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\ProductType">
<arguments>
<argument name="attributeCode" xsi:type="string">is_downloadable</argument>
<argument name="typeIdentifier" xsi:type="string">downloadable</argument>
<argument name="attributeLabel" xsi:type="string">Only downloadable products</argument>
</arguments>
</virtualType>
<virtualType name="isGiftCardProduct" type="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\ProductType">
<arguments>
<argument name="attributeCode" xsi:type="string">is_giftcard</argument>
<argument name="typeIdentifier" xsi:type="string">giftcard</argument>
<argument name="attributeLabel" xsi:type="string">Only giftcard products</argument>
</arguments>
</virtualType>
<virtualType name="isGroupedProduct" type="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\ProductType">
<arguments>
<argument name="attributeCode" xsi:type="string">is_grouped</argument>
<argument name="typeIdentifier" xsi:type="string">grouped</argument>
<argument name="attributeLabel" xsi:type="string">Only grouped products</argument>
</arguments>
</virtualType>
<virtualType name="isSimpleProduct" type="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\ProductType">
<arguments>
<argument name="attributeCode" xsi:type="string">is_simple</argument>
<argument name="typeIdentifier" xsi:type="string">simple</argument>
<argument name="attributeLabel" xsi:type="string">Only simple products</argument>
</arguments>
</virtualType>
<virtualType name="isCreatedWithinLastXdays" type="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\ProductDate">
<arguments>
<argument name="attributeCode" xsi:type="string">is_created_within_last_x_days</argument>
<argument name="attributeLabel" xsi:type="string">Product creation date (X days ago)</argument>
<argument name="fieldName" xsi:type="string">created_at</argument>
</arguments>
</virtualType>
<virtualType name="isUpdatedWithinLastXdays" type="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\ProductDate">
<arguments>
<argument name="attributeCode" xsi:type="string">is_updated_within_last_x_days</argument>
<argument name="attributeLabel" xsi:type="string">Product updation date (X days ago)</argument>
<argument name="fieldName" xsi:type="string">updated_at</argument>
</arguments>
</virtualType>
<preference for="Smile\ElasticsuiteCatalogRule\Api\Data\ConditionInterface" type="Smile\ElasticsuiteCatalogRule\Model\Data\Condition"/>
<!-- Session proxies -->
<type name="Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\SpecialAttribute\IsDiscount">
<arguments>
<argument name="customerSession" xsi:type="object">Magento\Customer\Model\Session\Proxy</argument>
</arguments>
</type>
</config>