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

Adding join, or where condition to product viewed report
 
pierzu
Jr. Member
 
Total Posts:  5
Joined:  2013-01-01
 

Hi

I want to customize product viewed report, to get products, which product_id is in other table.
So i want to add join to this table, or where condition with all product_id of this other table.

How can i do it?
I tried few ways without any results…

Probably i have to modify _prepareCollection in Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php, but as i said, i don\\\’t know how.

 
Magento Community Magento Community
Magento Community
Magento Community
 
varun931
Jr. Member
 
Avatar
Total Posts:  4
Joined:  2012-09-05
Jaipur
 

Hi

$collection->getSelect()->join('[table u want to join]''main_table.[joinfield] = [table u want to join].[joinfield]',array('[field you want to extract]') );

just after the

$collection = Mage::getResourceModel($this->_getCollectionClass());

in _prepareCollection in Mage/Adminhtml/Block/Report/Product/Viewed/Grid.php

 
Magento Community Magento Community
Magento Community
Magento Community
 
pierzu
Jr. Member
 
Total Posts:  5
Joined:  2013-01-01
 

Edited - that what i wrote was wrong.

I added after first getResourceModel:

$resourceCollection->getSelect()
->
join('designer_product''report_viewed_product_aggregated_daily.product_id = designer_product.product_id', array('designer_product.product_id as p_id''designer_product.designer_id'))
->
where('designer_product.designer_id=' Mage::registry('designer_data')->getId());

And before it switch, with period type checking.

If daily is selected, it is ok.
But when i select monthly, or yearly i have error:

SQLSTATE[21000]Cardinality violation1222 The used SELECT statements have a different number of columns

Ok, there are magically generated unions, and probably i have to create join to each union, am i right?

If yes, how can i do it?

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