6

In Magento 2, is there a way to get the assigned category ids for a given product, via Service Contracts?

The CategoryLinkManagementInterface API interface only has one method that returns the assigned products for a given category ID, but I need it the other way around.

4

I haven't found such method from the service contracts.

The only way I can see this working via a service contract is by using Magento\Catalog\Api\ProductRepositoryInterface to get the product first (via get or getById ) and then call getCategoryIds on that product.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.