1

I'm trying to build a custom grid in Magento, where I have a row for every product ordered including qty. For example, if a customer ordered 3 of a specific product - I need to have 3 rows that all have matching details. Is this possible?

This is for a custom product where each row represents a manufacturing run. I'm not necessarily looking for code examples, but I'm not sure if I can do this with the sql style collection process? Or if I need modify the query and loop through once I've colelcted all the data from the database?

Thanks

  • anything is possible :) if you show us your code and explain what the problem is we'll be able to help you – OSdave Oct 07 '13 at 15:24
  • The grid widget works off collections, is this just for single order or multiple orders? It is possible to get a collection of all sale_order_item then loop through the collection and duplicate the results based on the qty. but it is pretty inefficient. – jzahedieh Oct 07 '13 at 15:27
  • Another potential option is using a numbers table to join qty onto, hacky hacky. See: http://stackoverflow.com/questions/10423767/sql-repeat-a-result-row-multiple-times-and-number-the-rows – jzahedieh Oct 07 '13 at 15:45

1 Answers1

0

Instead of showing the product order item grid, I just added an export to xml button. Then, in the grid just modified the "_exportIterateCollection" method as the following:

        foreach ($collection as $item) {
            for($i = 0; $i < $item->getQtyOrdered(); $i++ ){
                call_user_func_array(array($this, $callback), array_merge(array($item), $args));
            }
        }

Hope this helps future questions!