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

Joinfield query
 
BoostMyShop
Sr. Member
 
Avatar
Total Posts:  155
Joined:  2008-06-11
France
 

Hello smile

i created my own table (orer_to_prepare) to add information regarding an order.

In this way, i created model class “class MDN_MageCustomization_Model_OrderToPrepare extends Mage_Core_Model_Abstract”

I successfully retrieve records with getcollection method.
I also succeed to add filter.

However, i’d like to retrieve information from both sales_order and OrderToPrepare tables.
OrderToPrepare contains a foreign key named order_id that refers to entity_id field.

So i try to get all fields from sales_order and OrderToPrepare using that relation.

I wrote that:

$this->_SelectedOrders Mage::getResourceModel('sales/order_collection')
            ->
addAttributeToSelect('*')
                             ->
addFieldToFilter('entity_id', array('in'=>$list_selected))                                ->joinField('shipment_created',
                            
'order_to_prepare',
                            
'shipment_created',
                            
'entity_id=order_id',
                            
'',
                            
'left');

However, it doesn’t work, i get the following error msg:

incorrect attribute name: order_id

Any idea ?

Thanks in advance !

 
Magento Community Magento Community
Magento Community
Magento Community
 
Juscelino
Jr. Member
 
Total Posts:  11
Joined:  2010-05-03
 

estou com o mesmo problema.

$collection Mage::getModel('catalog/product')->getCollection()
            ->
addAttributeToSelect('*')
            ->
joinField('qty',
                
'cataloginventory/stock_item',
                
'qty',
                
'product_id=entity_id',
                
'{{table}}.stock_id=1',
                
'left')    
                
            ->
joinField('fornecedor_razao',
                
'fornecedor'
                
'fornecedor_razao'
                
'fornecedor_id=produto_fornecedor',
                
null
                
'left');

“Nome inválido de atributo: produto_fornecedor”

só pra reforçar, na minha tabela catalog_product_entity tenho a coluna produto_fornecedor onde guardo o ID do fornecedor.

Alguém tem idéia de uma solução?

 
Magento Community Magento Community
Magento Community
Magento Community
 
MagePsycho
Moderator
 
Avatar
Total Posts:  1702
Joined:  2009-06-23
 

Skeletong Code for joing using collection:

$this->_SelectedOrders Mage::getResourceModel('sales/order_collection')->getSelect()->join(/*join here*/)->where(/*conditions*/);

Explore more about collections:
http://www.magentocommerce.com/wiki/development/using_collections_in_magento

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