Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returnrate #2

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions statsbestproducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ public function __construct()
'header' => $this->trans('Active', array(), 'Admin.Global'),
'dataIndex' => 'active',
'align' => 'center'
),
array(
'id' => 'returnrate',
'header' => $this->trans('% of return', array(), 'Modules.Statsbestproducts.Admin'),
'dataIndex' => 'returnrate',
'align' => 'center'
)
);

Expand Down Expand Up @@ -191,6 +197,16 @@ public function getData()
foreach ($values as &$value) {
$value['avgPriceSold'] = Tools::displayPrice($value['avgPriceSold'], $currency);
$value['totalPriceSold'] = Tools::displayPrice($value['totalPriceSold'], $currency);
$q = "SELECT count(oret.id_order_return) AS nr FROM "._DB_PREFIX_."order_return AS oret
LEFT JOIN "._DB_PREFIX_."order_return_detail AS ord ON (oret.id_order_return=ord.id_order_return)
LEFT JOIN "._DB_PREFIX_."order_detail AS od ON (ord.id_order_detail=od.id_order_detail)
LEFT JOIN "._DB_PREFIX_."product_attribute AS pa ON (od.product_attribute_id=pa.id_product_attribute)
LEFT JOIN "._DB_PREFIX_."order_return_state_lang AS status ON (oret.state=status.id_order_return_state)
WHERE status.id_lang='".(int)$this->getLang()."'
AND date_add BETWEEN $date_between
AND od.product_id='" . (int)$value['id_product'] . "';";
$nb = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($q);
$value['returnrate'] = round($nb / $value['totalQuantitySold'] * 100, 2);
}
unset($value);

Expand Down