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

How to set rules for virtual category via API in Magento 2? #1298

Closed
overjolted opened this issue Feb 10, 2019 · 5 comments
Closed

How to set rules for virtual category via API in Magento 2? #1298

overjolted opened this issue Feb 10, 2019 · 5 comments
Assignees

Comments

@overjolted
Copy link

overjolted commented Feb 10, 2019

Hello, thank you for a great suite, that you guys have developed.
I do have a question though:

How do I create a virtual category and set rules for it via API?

PS To see what it might look like, I manually created a virtual category and set rules for it, but when I retrieve info about this category via API, 'virtual_rule' value is just an empty list. Why is that? Where do I find en example for setting rule for a virtual category via API?

Thanks.

Preconditions

Magento Version :
Magento CE 2.3

ElasticSuite Version :
2.7.4

Environment :
Developer mode

Third party modules :
None

@romainruaud
Copy link
Collaborator

Hello @overjolted

thank you for supporting us :)

Just to be sure, do you mean "with the REST admin API" when speaking about "via API" ?

Regards

@overjolted
Copy link
Author

Hello @overjolted

thank you for supporting us :)

Just to be sure, do you mean "with the REST admin API" when speaking about "via API" ?

Regards

Yes, I mean REST API

@romainruaud romainruaud self-assigned this Apr 12, 2019
@romainruaud
Copy link
Collaborator

For now I have implemented the read part. Attribute is now showing up like this in REST response :

{
            "attribute_code": "virtual_rule",
            "value": {
                "condition": {
                    "condition_type": "Smile\\ElasticsuiteVirtualCategory\\Model\\Rule\\Condition\\Combine",
                    "conditions": [
                        {
                            "condition_type": "Smile\\ElasticsuiteVirtualCategory\\Model\\Rule\\Condition\\Product",
                            "operator": "{}",
                            "attribute_name": "sku",
                            "value": "24-MB01, 24-MB04, 24-MB03"
                        },
                        {
                            "condition_type": "Smile\\ElasticsuiteVirtualCategory\\Model\\Rule\\Condition\\Product",
                            "operator": "()",
                            "attribute_name": "color",
                            "value": [
                                "49",
                                "50",
                                "51",
                                "52"
                            ]
                        }
                    ],
                    "aggregator_type": "all",
                    "operator": null,
                    "value": "1"
                }
            }

@romainruaud
Copy link
Collaborator

Implemented in PR #1384

format to be used when creating/updating a virtual category is the same that I showed on previous comment.

Anyway, I'm not sure it's an easy step for anyone to create such kind of complex objects through an API... But I took insipiration from the Magento SalesRule API and mimiced it.

Regards

@romainruaud
Copy link
Collaborator

Fixed by associated PR. Will be part of next minor 2.7 release.

Thank you for reporting it.

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

No branches or pull requests

2 participants