3

I have a job at the minute that requires a third party (TP) system to add products to the magento cart. The third party hosts all product information and the pricing. The products being added to the cart will not be added to Magento directly (Catalog/Manage Products). I am looking to know if this is possible and if there are any resources that will help achieve this?

Basically, I am looking to add products to the cart and checkout without having the product created in magento. It will be sent to the website via GET/POST.

Thanks

2
+25

Try creating ONE product in magento admin to use as the "template" (to prevent Magento check to see if the product exists/enable issues).

Then create an observer that will update the CART item using the template product above

config.xml

<config>
...
    <global>
        <events>
            <sales_quote_item_set_product>
                <observers>
                    <samples>
                        <type>singleton</type>
                        <class>samples/observer</class>
                        <method>salesQuoteItemSetProduct</method>
                    </samples>
                </observers>
            </sales_quote_item_set_product>
        </events>
    <global>
...
</config>

Observer.php

class Mynamespace_Samples_Model_Observer
{
    public function salesQuoteItemSetProduct(Varien_Event_Observer $observer)
    {
        /* @var $item Mage_Sales_Model_Quote_Item */
        if($item->getId() == [template_product_id])
            $item = $observer->getQuoteItem();

            $item->setName($thirdPartyProductName);
            $item->setSku($thirdPartyProductSku);
            $item->setPrice($thirdPartyProductPrice);

        return $this;
    }
}

Limitation : You would only be able to add one product per cart unless you add more template product and map them correctly

See

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.