I know that we can adding a product to cart via querystring.
but how do we add sku to cart via querystring in url without including product id
like this :
domain/checkout/cart/add?sku=ABC
or
domain/checkout/cart/add/sku=BC
addtocartquerysku
I know that we can adding a product to cart via querystring.
but how do we add sku to cart via querystring in url without including product id
like this :
domain/checkout/cart/add?sku=ABC
or
domain/checkout/cart/add/sku=BC
Best Answer
Andhi Irawan,you can not do this type of work at
checkout Cart controllers
. If want this type of work then you need torewrite Checkout CartController.php
and on this class magento isload the product object by id
beforegoing to cart
,So you needload product by sku on
this place .Step 1: rewrite cartController.php and code is for xml rewrite
Step2: and on your extended
Cartcontorller
_initProduct
function you need product load product by skuHow to rewrite controller see more at : http://www.amitbera.com/how-to-override-a-controller-in-magento/