0

I have a product that get values from another script and I have a product attribute name custom_value, I want to set the values from another script programmatically. I tried different methods but could not get it done. I tried this, it didn't worked

$quoteItem = $observer->getItem();
if ($additionalOptions = $quoteItem->getOptionByCode('stamp_design')) {
$orderItem = $observer->getOrderItem();
$options = $orderItem->getProductOptions();
$options['stamp_design'] = unserialize($additionalOptions->getValue());
$orderItem->setProductOptions($options);
}

I also tried this and it also didn't worked.

    $product = $observer->getEvent()->getProduct();

    // Write a new line to var/log/product-updates.log
    $name = $product->getName();
    $sku = $product->getSku();

    $orderItem = $observer->getEvent()->getItem();
    $options = $product->getProductOptions();

    var_dump($options);
    $options['custom_value'] = $_SESSION['generated_value'];
    $product->setProductOptions($options);

    $options = $product->getOptions();

They are giving Fatal error: Call to a member function xxxx on a non-object.

Can everybody provide me some solution, Magento version is 1.7 thanks.

Shoaib Iqbal
  • 1,208
  • 11
  • 21

0 Answers0