5

I am working on the backend invoice template.

In adminhtml (sales/order/invoice/view/items.phtml), the item list is performed with :

<?php $_items = $this->getInvoice()->getAllItems() ?>
<?php $i=0;foreach ($_items as $_item): ?>
    <?php echo $this->getItemHtml($_item) ?>
    <?php echo $this->getItemExtraInfoHtml($_item->getOrderItem()) ?>
<?php endforeach; ?>

I would like to be able to access items custom options inside that loop.

I tried several things :

$_item->getOptions();
$_item->getProductOptions();
$_item->getItemOptions();
$_item->getProduct()->getTypeInstance(true)->getOrderOptions($_item->getProduct());

but none is working…

Thank you for your help,

  • $_item->getProductOptions() should be the one. What happens when you var_dump it? Does it return NULL? – Mayers May 16 '15 at 15:13
  • in fact, I extended the Adminhtml/Sales/Order/Invoice/View/Items.php, with a custom function that performs $_items = $this->getInvoice()->getAllItems(); and a loop with $options = $_item->getItemOptions(); . I then try foreach ($options as $option) which returns an error "Invalid argument supplied for foreach()" – Alexglvr May 19 '15 at 20:55
2

here is the solution: $_options = $_item->getOrderItem()->getProductOptions();

| improve this answer | |

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.