0

I have created a custom product level attribute in magento now I want that attribute in my cart so I created the column in quote item table now I need the value of that attribute, while adding products into cart. I am facing issue when I add configurable product in cart.

This is my code

public function salesQuoteItemSetCustomAttribute($observer)
{
    $quoteItem = $observer->getQuoteItem();
    $product = $observer->getProduct();
    $quoteItem->setCustomAttribute($product->getCustomAttribute());
}

It returns me configurable attribute value not the child products or simple products attribute value

  • How did you create the column in quote_item table? Directly in the database or through any extension? – Sukumar Gorai Dec 19 '18 at 10:08
  • using script sss – aaaa Dec 19 '18 at 10:27
  • Can you update what you have tried and how you have added the attribute? Also do you want to update the same to order_item as well? – Sukumar Gorai Dec 19 '18 at 10:29
0

You can use below code to get child products of current configurable product.

$product = Mage::getModel('catalog/product')->load(3); // configurable product Id
$childProducts = Mage::getModel('catalog/product_type_configurable')
                ->getUsedProducts(null,$product);

foreach($childProducts as $child) {
print_r($child->getName());  // You can use any of the magic get functions on this object to get the value

UPDATE :

$childProducts = Mage::getModel('catalog/product_type_configurable')
                ->getChildrenIds(3);
}
| improve this answer | |
  • but it will increse the add time ? – aaaa Dec 19 '18 at 6:13
  • because i have exetnsion which add multiple product at a time – aaaa Dec 19 '18 at 6:14
  • Check my edit . – anonymous Dec 19 '18 at 6:14

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.