Reputation: 1264
As above, I've got a strange issue where every other product I add isn't added to the cart or quote in Magento.
It's repeatable, in that I can add one product, then the next one doesn't add (but I do get a status messaging saying it was added), and then the next done after that adds as it should do.
It's not specific to a product, as if I add the same product a second time it will add as expected.
The only thing we have that's a little different is an observer called on the sales_quote_add_item event, but that's just changing the pricing:
public function update_book_price(Varien_Event_Observer $observer) {
//get the admin session
Mage::getSingleton('core/session', array('name'=>'adminhtml'));
if (!$quoteitem = $observer->getQuoteItem()){
$quoteitem = $observer->getItem();
}
if (!$item = $observer->getEvent()->getQuoteItem()){
$item = $quoteitem;
}
$quote = $item->getQuote();
$product = $item->getProduct();
$price = Mage::helper('users')->getCustomerProductPrice(false,Mage::getModel('catalog/product')->load($product['product_id']),false,true,$_POST['qtys'][$product['product_id']]);
echo "Price : $price \n";
//print_r($price);
$price = $price;
if(!$quoteitem->setOriginalCustomPrice($price)) {
echo "Couldn't set price";
}
else {
echo "price updated, save";
try {
$quoteitem->getProduct()->setIsSuperMode(true);
var_dump($quoteitem->save());
}catch(Exception $e){
echo $e->getMessage() . "\n";
}
}
return $this;
}
I've checked at a DB level, and the missing items are not even in the DB - sales_flat_quote_item has no record of them, but the 'working' items are in as normal.
Has anyone experienced anything like this before, or can anyone suggest where I might start investigating? Thanks!
Upvotes: 1
Views: 267
Reputation: 8050
You don't have to save quote item after changing price.
Delete var_dump($quoteitem->save());
and try again.
Upvotes: 1