0

I'm busy creating an order programmatically, and want the process to add the product list to the order regardless of the product status.

It works fine, but when the product has a status of disabled (i.e status value is 2) then the price that is saved is 0.00. (I see this in the sales_flat_quote_item table).

I've tried calling Mage::helper('catalog/product')->setSkipSaleableCheck(true); but that doesn't help either.

Here's the full code

foreach ($product_ids as $id){
            $product = Mage::getModel('catalog/product');
            $product->load($id);
            $product_info = array('qty'=>$product_qtys[$counter]);
            $quote->addProduct($product, new Varien_Object($product_info));
            $counter++;
        }

I've also tried using custom pricing, and that doesn't seem to affect the price on the quote at all. Any ideas?

2

The workaround I used was as follows:

 foreach ($product_ids as $id){
            $product = Mage::getModel('catalog/product');
            $product->load($id);
            $product_info = array('qty'=>$product_qtys[$counter]);
            $product->setStatus(1);//enabled, but don't save changes, works 100%
            $quote_item = $quote->addProduct($product, new Varien_Object($product_info));
            $quote_item->setCustomPrice($pricing[$counter]);
            $quote_item->setOriginalCustomPrice($pricing[$counter]);
            $quote_item->getProduct()->setIsSuperMode(true);
            $counter++;
        }
$quote->save();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.