i'm trying append string abc name of each item added cart. should show in cart/checkout , accessible programmatically.
so far, have overloaded mage_checkout_cartcontroller custom abc_def_cartcontroller such:
<frontend> <routers> <checkout> <args> <modules> <abc_def before='mage_checkout'>abc_def</abc_def> </modules> </args> </checkout> </routers> </frontend> new cartcontroller.php overloades addaction():
public function addaction(){ //prepare $cart = $this->_getcart(); $params = $this->getrequest()->getparams(); $params['qty']=1; try{ $product = $this->_initproduct(); $product->setdata('qty',1); if(!$product){ //todo product not found return; } $product->setdata('name',$product->getname()."abc"); $cart->addproduct($product,$params); $cart->save(); $this->_getsession()->setcartwasupdated(true); mage::dispatchevent('checkout_cart_add_product_complete', array('product' => $product, 'request' => $this->getrequest(), 'response' => $this->getresponse()) ); } catch (exception $e) { //todo mage::logexception($e); } by understanding, basic product information re-loaded database somewhere cannot figure or how make changes persistent. in advance.
i think better hook onto event sales_quote_item_set_product. event dispatched in mage_sales_model_quote_item::setproduct().
prior dispatching event there line:
->setname($product->getname()) so assume can change name in custom observer event mentioned.
event receives parameters current quote item , product assigned it.
Comments
Post a Comment