如何在与zend的会话中添加产品?我接收产品作为数组
我试过这个,但不管用
还有你是如何在另一次行动中进行这一阶段的..。
很多
public function incartAction(){
$this->_helper->_layout->disableLayout();
$id = $this->_getParam("id");
$name= $this->_getParam("name");
$price= $this->getParam("price");
$img = $this->_getParam("img");
$qty = $this->_getParam("qty");
$produs = array(
"id"=>$id,
"name"=>$name,
"price"=>$price,
"img"=>$img,
"qty"=>$qty
);
$produs_model = new Application_Model_DbTable_Produs;
$produs_model->updateProdusById($id, $qty);
$cart = new Zend_Session_Namespace("products");
$cart->products->$name= $product;
$this->view->assign("cart", $cart);
}发布于 2014-01-09 06:06:29
你做错了,变量名也错了,
这是你怎么做的
首先在控制器中定义它,
public function incartAction(){
$product = array(
"id"=>$id,
"name"=>$name,
"price"=>$price,
"img"=>$img,
"qty"=>$qty
);
//add it to session variable [in same controller]
$cart = new Zend_Session_Namespace("products");
$cart->product= $product;
}现在用在另一个控制器上,
public function outcartAction(){
$cart = new Zend_Session_Namespace("products");
$product= $cart->product;
print_r($product);
}https://stackoverflow.com/questions/21004664
复制相似问题