2

In my magento store, I have implemented a custom module to add configurable products programmatically. In those products I have added Custom Option, a text field for user to input some data.

Now I have this requirement of retrieving all the values of the custom option entered by users who purchased the specific product. (I need to retrieve the values using the product ID)

Is there a way I can achieve this?

7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Jun 5, 2015 at 6:14
2
  • Can you explain a little more what exactly is doing your module ? For example : In which table is the data of this custom option registered ? Commented Jun 5, 2015 at 7:59
  • it's a module to create configurable products programmatically and each configurable product contains a custom option where the customer can enter their name. Commented Jun 5, 2015 at 8:07

2 Answers 2

4

Check product_options column in sales_flat_order_item table.

You can use order_item collection and get the value of that field like that:

$orderItems = Mage::getModel('sales/order_item')->getCollection()->addFieldToFilter('product_id', '123');
foreach($orderItems as $orderItem){
 $options = $orderItem->getProductOptions();
 var_dump($options);
}
answered Jun 5, 2015 at 9:57
0
4

You need use this code to get custom options of the product:

 if($_product->hasOptions()) {
 foreach($_product->getOptions() as $option) {
 echo 'Option title is: ' . $option->getTitle();
 echo 'Option type is: ' . $option->getType();
 echo 'Option values:';
 foreach($option->getValues() as $value) {
 echo '- ' . $value->getTitle() . ': ' . $value->getPrice();
 }
 }
 }
answered Aug 28, 2016 at 8:58

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.