0

a client wants a page where he can sees custom options from his product, I managed to duplicate Sales > Order, and then custom that page to display the custom options.

Problem is, only one of these items have custom options, and on Sales > Orders you see all orders, of course you can just type in the SKU (I put the column SKU too), but I wanted it to automatically bring all orders from that SKU. On Grid.php here what I have:

protected function _prepareCollection()
    {
        $collection = Mage::getResourceModel($this->_getCollectionClass())
        ->join(
        'sales/order_item',
        '`sales/order_item`.order_id=`main_table`.entity_id',
        array(
        'skus' => new Zend_Db_Expr('group_concat(`sales/order_item`.sku SEPARATOR ",")'),
        ));

        $collection->getSelect()->group('main_table.entity_id');

        $collection->getSelect()->joinLeft(array('sfoi' => 'sales_flat_order_item'), 
        'main_table.entity_id = sfoi.order_id', 
        array('sfoi.product_options'));

        $collection->getSelect()->join('sales_flat_order', 'main_table.entity_id = sales_flat_order.entity_id',array('coupon_code'));

        $this->setCollection($collection);

        return parent::_prepareCollection();
    }

With this I can get SKU, product options, and the coupon codes used. How can I set it to return only the SKU SD0003?

Thanks

duplode
  • 33,731
  • 7
  • 79
  • 150

1 Answers1

1

Try this:

$collection->getSelect()->where('sfoi.sku = "' . $yourDesireSku . '"');

Greetings.

Beto Castillo
  • 867
  • 9
  • 16
  • Thank you! Worked perfectly, and I googled a lot about it and the answer was so simply lol. I'm new to stackoverflow so I don't know how I can recommend you, mind telling? I marked the answer as well – Rafael Elias Jul 30 '13 at 16:44
  • Click the "upper" button, on the left side to the question. And glad to help you, greetings from México. – Beto Castillo Jul 30 '13 at 16:53