1

How can i get item custom option from shipment item

my code is as

I am tring to get this using $options = $item->getProductOptions(); but it gives blank.

    <?php $_order = $this->getOrder() ?>
<?php $group = $this->getGroupcode(); ?>
<?php $shipmentId = $this->getShipmentid(); ?>
<?php if ($_order): ?>
<?php foreach($_order->getShipmentsCollection() as $shipment): ?>
    <?php foreach($shipment->getItemsCollection() as $item): ?>
        <?php
        $options = $item->getProductOptions();
        echo "<pre/>";print_r($item->getData());exit;
        $lineId = $options['info_buyRequest']['additional_options']['productline_id'];
        $groupId = Mage::getModel('productline/productline')->load($lineId)->getShippinggroup();
        if(!empty($options['info_buyRequest']['additional_options']['item_shippinggroup'])){
            $itemGroup = $options['info_buyRequest']['additional_options']['item_shippinggroup'];
        }else{
            $itemGroup =  trim(Mage::getModel('shippinggroup/shippinggroup')->load($groupId)->getTitle());
        }
        ?>
        <?php if($group == $itemGroup && $shipmentId == $shipment->getIncrementId()): ?>
        <?php echo $this->getItemHtml($_item) ?>
        <?php endif; ?>
    <?php endforeach; ?>
<?php endforeach; ?>
<?php endif; ?>

1 Answer 1

1

You will get order item detail only in order item table, not in shipment item table. You can try this to get item detail :

<?php $_order = $this->getOrder() ?>
<?php $group = $this->getGroupcode(); ?>
<?php $shipmentId = $this->getShipmentid(); ?>
<?php if ($_order): ?>
<?php foreach($_order->getShipmentsCollection() as $shipment): ?>
    <?php foreach($shipment->getItemsCollection() as $item): ?>
    <?php
    $options = $item->getProductOptions();
    $orderItem = Mage::getModel('sales/order_item')->load($item->getOrderItemId());
    echo "<pre/>";print_r($orderItem->getData());exit;
    //echo "<pre/>";print_r($item->getData());exit;
    $lineId = $options['info_buyRequest']['additional_options']['productline_id'];
    $groupId = Mage::getModel('productline/productline')->load($lineId)->getShippinggroup();
    if(!empty($options['info_buyRequest']['additional_options']['item_shippinggroup'])){
        $itemGroup = $options['info_buyRequest']['additional_options']['item_shippinggroup'];
    }else{
        $itemGroup =  trim(Mage::getModel('shippinggroup/shippinggroup')->load($groupId)->getTitle());
    }
    ?>
    <?php if($group == $itemGroup && $shipmentId == $shipment->getIncrementId()): ?>
    <?php echo $this->getItemHtml($_item) ?>
    <?php endif; ?>
    <?php endforeach; ?>
<?php endforeach; ?>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.