1

I'm using an extension from a 3rd party manufacturer. This extension requires that we set an iframe to their product form on our site, then we use the index controller in their module to send their product data to the cart. Here's the important bits from the index controller:

$data = $this->getRequest()->getParams();
$sku = $data['gpart'];
$options['description'] = $data['description'];
$options['part_num'] = $data['part'];
$params['qty'] = $data['quantity'];

$cart = Mage::getSingleton('checkout/cart');
$prod = Mage::getModel('catalog/product');
$prod_id = $prod->getIdBySku($sku);
$product = $prod->load($prod_id);

$additionalOptions = array();

if ($additionalOption = $product->getCustomOption('additional_options')) {
    $additionalOptions = (array) unserialize($additionalOption->getValue());
}

foreach ($options as $key => $value) {
    $additionalOptions[] = array(
        'label' => $key,
        'value' => $value,
     );
 }

$product->addCustomOption('additional_options',serialize($additionalOptions));
$product->setProductOptions($data['description']);
$cart->addProduct($product, $params);
$cart->save();

$url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'checkout/cart';

echo "<script type=\"text/javascript\">window.onload = window.top.location.href=\"$url\";</script>";

As you may be able to tell, this intercepts a request to a certain url and gets paramaters from it to build the quote item. The main issue I am having is with the $product->setProductOptions(); and $product->addCustomOption();

While this information is being saved to the table sales_flat_quote_item_option, this data is not being sent to the cart on checkout. In other words, 'additional_options' exists in 'sales_flat_quote_item_option', but does not transfer over to 'product_options' with the rest of the custom options in 'sales_flat_order_item'.

I'm lost. I've been working in magento for three weeks so I'm sure this is common stuff further down the road, but I'd really appreciate some help. Thanks!

Your Answer

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

Browse other questions tagged or ask your own question.