magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

[Issue] Allow custom catalog rule conditions #39339

Open m2-assistant[bot] opened 1 week ago

m2-assistant[bot] commented 1 week ago

This issue is automatically created based on existing pull request: magento/magento2#39332: Allow custom catalog rule conditions


Description (*)

Due to the check based on object attribute there is no way to use custom implementations for catalog rule validation

$condition->getType() === SimpleCondition::class

Related Pull Requests

Fixed Issues (if relevant)

1.

Manual testing scenarios (*)

  1. Create custom catalog rule with custom object
  2. Use custom validation logic

Expected Result:

  1. Magento should create and allow custom classes in catalog rules Current Result:
  2. Magento creates only SimpleCondition object so custom implementation is not possible

Questions or comments

In SalesRule module there is a way to use custom classes and objects but not in catalog rules module.

Contribution checklist (*)

m2-assistant[bot] commented 4 days ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 4 days ago

Hello @ilnytskyi,

Thanks for the report and collaboration!

We have reviewed the codebase of the below file:

https://github.com/magento/magento2/blob/0b488dd1139e413cd5711241ae767030081805f6/app/code/Magento/CatalogRule/Model/Rule/Condition/ConditionsToSearchCriteriaMapper.php#L85-L89

And compare the changes made in the PR.

$condition->getType() === CombinedCondition::class: This code compares the result of the getType() method of the $condition object with the fully qualified class name of CombinedCondition. It checks if the type returned by getType() is exactly the same as the CombinedCondition class name.

And

$condition instanceof CombinedCondition: This code checks if the $condition object is an instance of the CombinedCondition class or any of its subclasses. It is a more direct way to check the type of an object. Which seems relevant. Hence confirming this issue for further processing.

Thanks

github-jira-sync-bot commented 4 days ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-13338 is successfully created for this GitHub issue.

m2-assistant[bot] commented 4 days ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.