I need to get at cart what category the product came from. The problem is that the product is added to several different categories, and I need the category in which the user accessed to add the product to the cart. I tried many different things but I couldn't get out of the place. Has anyone done something like this before?
magento does not store product category name where user added it. You need to do customise it.
For it you need to create custom column in order_item and quote_item table and with observer (checkout_cart_product_add_before) need to save current category name.
$category = Mage::registry('current_category'); $categoryid =$category->getId();