1

I want to show values from Custom option text field in product view page if customer already ordered the product. I don't have fixed options attribute they may change like custom size, sleeve size, etc. I am trying following code and fetch last order. I don't know how to get product custom options (text field) attribute dynamically.

if(Mage::getSingleton('customer/session')->isLoggedIn()){ 
 $customer = Mage::getSingleton('customer/session')->getCustomer();
 $email= $customer->getEmail();
 $_customer = Mage::getModel('customer/customer');
 // get order id
 $orders1 = Mage::getResourceModel('sales/order_collection')
 ->addFieldToSelect('*')
 ->addFilter('customer_email', $email)
 ->addAttributeToSort('created_at', 'DESC')
 ->setPageSize(1);
 $id= $orders1->getFirstItem()->getId(); 
 $order = Mage::getModel('sales/order')->load($id);
 //get all items
 $items = $order->getAllItems();
 $itemcount= count($items);
 $data = array();
 $i=0;
 //loop for all order items
 foreach ($items as $itemId => $item)
 {
 $data[$i]['name'] = $item->getName();
 $data[$i]['attr'] = $item->getAttributeName();
 }
Muhammad Anas
1,4673 gold badges13 silver badges33 bronze badges
asked Oct 23, 2015 at 6:46

1 Answer 1

0

If I understand well you have configurable products. Therefore, with the product id or sku, you can retrieve the different data you need to display on the product view.

If you want to stock the attribute in the quote and in the order item, you can also read this article : http://www.atwix.com/magento/custom-product-attribute-quote-order-item/

Additionnaly, I would better stock the attribute with the customer if it is customer relative data. It would help if one day you want to have preselected sleeves length or belt size on any product.

answered Oct 23, 2015 at 7:02
2
  • yes i just want all the custom option value to be displayed if user want to order the product again Commented Oct 23, 2015 at 7:07
  • you can retrieve this custom options from the configurable product that you can load with the product id of the item. Commented Oct 23, 2015 at 7:21

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.