Magento Module: SKUs by Coupon Report

A built-in reporting tool that provides SKU-level data for coupon usage.

Details

This module was developed to provide a custom report on SKUs purchased by coupon code. By selecting a date range and a coupon code, the merchant can generate a report of all SKUs purchased with that coupon. This report was built on top of native Magento reporting tools, employing a consistent interface and filter options.

Screenshots

Generating reports

Technical Features

Code Sample

protected function _initSelect()
{
    $filterData = Mage::registry('groove_filter_data');

    if (!$filterData) {
        $filterData = new Varien_Object();
    }

    $this->getSelect()
        ->from(
            array('main_table' => $this->getResource()->getMainTable()),
            $this->_getSelectedColumns()
        )
        ->join(
            array('sfo' => Mage::getSingleton('core/resource')->getTableName('sales/order')),
            'main_table.order_id = sfo.entity_id',
            array('coupon_code')
        );

    if ($filterData->getCoupon()) {
        $this->getSelect()
            ->where('sfo.coupon_code = ?', $filterData->getCoupon());
    }

    if ($this->isSubTotals()) {
        $this->getSelect()->group($this->_periodFormat);
    } else if (!$this->isTotals()) {
        $this->getSelect()
            ->group(
                array(
                    $this->_periodFormat,
                    'main_table.sku'
                )
            );
    }

    return $this;
}

Static Analysis