Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

[SOLVED] Join statement on module causing errors - please look at this code for me
 
tomharding
Member
 
Avatar
Total Posts:  63
Joined:  2011-03-24
 

Hi.

I’m hoping you database buffs would be able to help me out here.

I’m currently using the qikDropShipper module. While it’s been an excellent solution, parts of it have been badly coded (well I think so). It’s worked fine, up until someone ordered 2 items at once.

I get the error Item (Mage_Sales_Model_Order) with the same id “78” already exist. I’ve traced it down to a join statement in the modules code folder:

$collection Mage::getModel('sales/order')->getCollection();
    
$collection->getSelect()
            ->
join(array('oi' => $helper->getTableName('sales_flat_order_item')), 'oi.order_id=main_table.entity_id', array('oi.*'))
            ->
join(array('pei' => $helper->getTableName('catalog_product_entity_int')), 'pei.entity_id=oi.product_id', array())
            ->
joinNatural(array('ea' => $helper->getTableName('eav_attribute')))
            ->
join(array('vendors' => $helper->getTableName('vendors')), 'vendors.vendor_code=pei.value', array('vendors.company_name'))
            ->
where('ea.attribute_code="manufacturer"')
            
    ;

Does anything stand out here that could be contributing to this error?

I looked at the sales_flat_order_item table and 78 is the only repeated ID in there.

If anyone out there could point me in the right direction, I would love you forever.

Thanks,
Tom

 
Magento Community Magento Community
Magento Community
Magento Community
 
tomharding
Member
 
Avatar
Total Posts:  63
Joined:  2011-03-24
 

Fixed! I can’t believe it. I never fix Magento errors, it never happens.

Solution was simple.

Add the following somewhere in the statement:

->group('oi.order_id')

Basically, it was because you need to group the id that was causing the error. It’s never normally that easy with Magento smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
shangxie
Jr. Member
 
Total Posts:  2
Joined:  2012-05-28
 

hi~ i also I get the error Item (Mage_Sales_Model_Order) with the same id “1” already exist.  could you tell me where the modules code folder path is ?  thanks

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top