프로그래밍 방식으로 견적 항목을 업데이트할 수 없습니다.
-
29-09-2020 - |
문제
프로그래밍 방식으로 견적 항목을 업데이트하고 싶습니다.
나는 아래에서 노력하고있다
$walletAmount = Mage::app()->getRequest()->getPost('walletAmount'); //i AM GETTING THIS VALUE THROUGH AN AJAX REQUEST
$item = Mage::getModel('sales/quote_item')->load($rowQuoteId); // $rowQuoteId CONTAINS item_id OF THE `sales_flat_quote_item` TABLE.
$item->setWalletAmount($walletAmount);
$item->getProduct()->setIsSuperMode(true);
$item->save();
하지만 이 코드 위에는 아래와 같은 오류 메시지가 표시됩니다.
치명적 오류:\app\code\core\Mage\Sales\Model\Quote\Item\Abstract.php에 있는 비객체에 대한 멤버 함수 getStoreId()를 온라인으로 호출합니다.
해결책
직접 전화하는 것보다 매출/견적_항목 모델,사용 결제/카트 싱글톤 모델(Mage::getSingleton('checkout/cart'))
문제가 해결될 것입니다.
아래 코드를 시도해 보세요:
$cart=Mage::getSingleton('checkout/cart'); $item = $cart->getQuote()->getItemById($rowQuoteId); $item->getProduct()->setIsSuperMode(true); $item->setWalletAmount($walletAmount)->save(); $cart->save();
다른 팁
여기에 GetStoreID ()가 mage_sales_model_quote_item_abstract에서 언급 된 유일한 위치입니다.
$product = $this->_getData('product');
if ($product === null && $this->getProductId()) {
$product = Mage::getModel('catalog/product')
->setStoreId($this->getQuote()->getStoreId())
->load($this->getProductId());
$this->setProduct($product);
}
.
$ this-> getquote ()의 문제가있는 것 같습니다.견적이 있는지 확인하십시오. 어쨌든, 당신은 제품을 수동으로 설정할 수 있습니다 :
$walletAmount = Mage::app()->getRequest()->getPost('walletAmount'); //i AM GETTING THIS VALUE THROUGH AN AJAX REQUEST
$item = Mage::getModel('sales/quote_item')->load($rowQuoteId); // $rowQuoteId CONTAINS item_id OF THE `sales_flat_quote_item` TABLE.
$item->setWalletAmount($walletAmount);
$product = Mage::getModel('catalog/product')
->setStoreId($item->getStoreId())
->load($item->getProductId());
$item->setProduct($product);
$item->getProduct()->setIsSuperMode(true);
$item->save();
. 제휴하지 않습니다 magento.stackexchange