From eed30ea2f7471109cd41ed354de552b291993bd5 Mon Sep 17 00:00:00 2001
From: adam ling <997506412@qq.com>
Date: Mon, 14 May 2018 12:02:48 +0800
Subject: [PATCH 1/2] 201805141202
---
.../Block/Widget/Grid/Column/Renderer/Producturl.php | 9 ++++++++-
.../Martin/SalesReports/Block/Adminhtml/New/Grid.php | 7 +++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php
index 45996f6a..4b7f6c7b 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php
@@ -45,7 +45,14 @@ public function render(Varien_Object $row)
{
$actions = $this->getColumn()->getActions();
$field = $this->getColumn()->getField();
- $url = 'https://www.bellecat.com/en/catalog/product/view/id/'.$row->getData($field);
+ $product_id = $row->getData($field);
+
+ $adapter = Mage::getSingleton('core/resource')->getConnection('core_write');
+ $ur_result = $adapter->query("SELECT * FROM `core_url_rewrite` WHERE product_id='".$product_id."' AND category_id IS NULL LIMIT 1");
+ $url = $ur_result->fetch();
+ $url = 'https://www.bellecat.com/en/'.$url['request_path'];
+ //$url = 'https://www.bellecat.com/en/catalog/product/view/id/'.$row->getData($field);
+
return ''.$this->getColumn()->getHeader().'';
}
}
diff --git a/app/code/local/Martin/SalesReports/Block/Adminhtml/New/Grid.php b/app/code/local/Martin/SalesReports/Block/Adminhtml/New/Grid.php
index 6d9a8c49..42be8438 100644
--- a/app/code/local/Martin/SalesReports/Block/Adminhtml/New/Grid.php
+++ b/app/code/local/Martin/SalesReports/Block/Adminhtml/New/Grid.php
@@ -67,6 +67,7 @@ protected function _prepareCollection()
->columns("SUM(IF(order.status='complete' OR order.status='processing',oi.qty_ordered,0)) as num")
->joinLeft('sales_flat_order_item as oi','oi.product_id=e.entity_id','')
->joinLeft('sales_flat_order AS order',"oi.order_id=order.entity_id and (order.status='complete' or order.status='processing')",'')
+ ->joinLeft("cataloginventory_stock_status_idx as stock","stock.product_id=oi.product_id and stock.website_id=1",'ROUND(9999-stock.qty) as stock_num')
//->where('order.created_at>=?',array('from'=>$from))
//->where('order.created_at',array('to'=>$to))
//->where("order.status='complete' OR order.status='processing'")
@@ -139,6 +140,12 @@ protected function _prepareColumns()
'type' => 'number'
));
+ $this->addColumn('stock', array(
+ 'header' => Mage::helper('customer')->__('Stock'),
+ 'index' => 'stock_num',
+ 'type' => 'number'
+ ));
+
$this->addColumn('created_at', array(
'header' => Mage::helper('customer')->__('Created At'),
'index' => 'created_at',
From 51e5cc7bf344a4c8f67a1e91b962672e1092cce5 Mon Sep 17 00:00:00 2001
From: adam ling <997506412@qq.com>
Date: Mon, 14 May 2018 12:07:16 +0800
Subject: [PATCH 2/2] 201805141207
---
.../Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php
index 4b7f6c7b..8a2806da 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Producturl.php
@@ -50,7 +50,7 @@ public function render(Varien_Object $row)
$adapter = Mage::getSingleton('core/resource')->getConnection('core_write');
$ur_result = $adapter->query("SELECT * FROM `core_url_rewrite` WHERE product_id='".$product_id."' AND category_id IS NULL LIMIT 1");
$url = $ur_result->fetch();
- $url = 'https://www.bellecat.com/en/'.$url['request_path'];
+ $url = 'https://www.bellecat.com/en/'.(isset($url['request_path'])?$url['request_path']:'');
//$url = 'https://www.bellecat.com/en/catalog/product/view/id/'.$row->getData($field);
return ''.$this->getColumn()->getHeader().'';