how can i get sales report based on customer group
Bacially i want to add extra filter customer group to amdin > report > sales > order
How i can do it pls help , if possible via module observer will be helpful
how can i get sales report based on customer group
Bacially i want to add extra filter customer group to amdin > report > sales > order
How i can do it pls help , if possible via module observer will be helpful
Adding the form filter field can be done easily via observer like this:
In your module config.xml
<config>
<adminhtml>
<events>
<adminhtml_block_html_before>
<observers>
<yourmodule_append_custom_sales_report_filters>
<type>singleton</type>
<class>yourmodule/observer</class>
<method>appendCustomSalesReportFilters</method>
</yourmodule_append_custom_sales_report_filters>
</observers>
</adminhtml_block_html_before>
</events>
</adminhtml>
</config>
In your Observer:
public function appendCustomSalesReportFilters($_observer)
{
$_block = $_observer->getBlock();
if (!isset($_block)) {
return $this;
}
//Mage_Sales_Block_Adminhtml_Report_Filter_Form_Order
Mage::log($_block->getType());
if ($_block->getType() == 'sales/adminhtml_report_filter_form_order') {
$_form = $_block->getForm();
$fieldset = $_form->getElement('base_fieldset');
$fieldset->addField('some_field', 'text', array(
'name' => 'some_field',
'label' => Mage::helper('cms')->__('Some Field'),
'title' => Mage::helper('cms')->__('Some Field'),
)
);
}
}
This will add your custom field to the filter form of the Sales Report.
Further, try to do the same to add the grid column. Afterwards, check if filter works by default, as I think the grid collection collects the grid columns and applies the filters from the form by default. If not, you'll have to rewrite some collection.
Just change customer_id to group_id. Then you have the group_id.
But I think you can't add the customer group name. The problem is, that you need to first join from sales_flat_order_grid to sales_flat_order and then to customer_group. The second join can't be made at the moment. At least I didn't find fast a way. You are welcome to read in https://github.com/magento-hackathon/GridControl/blob/master/src/app/code/community/FireGento/GridControl/Model/Observer.php maybe you find a way.
If not feel free to send a PR to join tables without fields :-)