When you create a configurable product it doesn't matter what's the price of simple products -- these prices are ignored completely. So if you want to sell a simple product A which has price $29.99 and a simple product B ($39.99) then you must create a configurable product, set its price to $29.99 and open Associated product tab. Add products you want to associate with this configurable product. After adding them a block named Super product attributes configuration appears which contains options and price differences. Leave product A price empty and put 10 (+$10) to product B price field and voila: different simple product have different price.
There's actually an extension that allows you to use simple product prices instead of price differences, but it's kind of tricky to set up. Since it's free extension, I hope nobody complains about me pasting its link here:
https://github.com/organicinternet/magento-configurable-simple
Naing,add parent id filter
$collection = Mage::getModel('sales/order_item')->getCollection()
->addFieldToSelect(array('order_id','sku','name','qty_ordered','product_id','product_options','row_total'))
//->setOrder('main_table.order_id', 'desc');
->setOrder('main_table.created_at', 'desc');
// $collection->getSelect()->group('main_table.order_id');
To
$collection = Mage::getModel('sales/order_item')->getCollection()
->addFieldToSelect(array('order_id','sku','name','qty_ordered','product_id','product_options','row_total'))
->addFieldToFilter('parent_item_id',array(
'null' => true,
))->setOrder('main_table.created_at', 'desc');
Best Answer
the code below should work only if the simple products are assigned to only one configurable product.
by default, magento allows you to add a simple product to as many configurable products you need.
Let's create a module and call it
StackExchange_Redirect
.You will need the following files.
app/etc/modules/StackExchange_Redirect.xml
- the declaration fileapp/code/local/StackExchange/Redirect/etc/config.xml
- the module configuration file where you declare an observer for the product view pageapp/code/local/StackExchange/Redirect/Model/Observer.php
- the observer that should redirect to the configurable product page.when you are done, clear the cache.