2

I want to get category Id from order Item.

As we aware that we can get current_category on the product page.

but how to get that category from orderItem object.

We can get Product object via $orderItem->getProduct() but,

I am getting categoryIds() but I want specific Category Id where the user come and add that product to cart.

  • 2
    I think we must save category id in quote_item while adding the product to cart and then move that category id value into order_item. So, for this feature, we need to add the new attribute in quote item and order item. – kunj May 24 '18 at 9:07
0

I think Magento doesn't store that category id further means in quote.

So what easy solution you can do is add a hidden field in addtocart form

So that way you can get detail on info_buyRequest

for example <input type="hidden" name="cat_id" value="$catId" >

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.