From 5df032baf86165220027016817d89d0a1d635ed9 Mon Sep 17 00:00:00 2001
From: adam ling <997506412@qq.com>
Date: Thu, 10 May 2018 10:46:34 +0800
Subject: [PATCH] 201805101046
---
.../Adminhtml/Block/Widget/Grid/Column.php | 6 +++
.../Widget/Grid/Column/Renderer/Image.php | 50 +++++++++++++++++++
.../Grid/Column/Renderer/Recommendurl.php | 50 +++++++++++++++++++
.../Block/Adminhtml/Recommend/Grid.php | 6 +++
.../Block/Adminhtml/Product/Grid.php | 7 +++
5 files changed, 119 insertions(+)
create mode 100644 app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Image.php
create mode 100644 app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Recommendurl.php
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php
index 306fb1c8..164bb7c7 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php
@@ -268,6 +268,12 @@ protected function _getRendererByType()
case 'theme':
$rendererClass = 'adminhtml/widget_grid_column_renderer_theme';
break;
+ case 'recommend_url':
+ $rendererClass = 'adminhtml/widget_grid_column_renderer_recommendurl';
+ break;
+ case 'image':
+ $rendererClass = 'adminhtml/widget_grid_column_renderer_image';
+ break;
default:
$rendererClass = 'adminhtml/widget_grid_column_renderer_text';
break;
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Image.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Image.php
new file mode 100644
index 00000000..82c9318e
--- /dev/null
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Image.php
@@ -0,0 +1,50 @@
+
+ */
+class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Image
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
+{
+
+ /**
+ * Renders column
+ *
+ * @param Varien_Object $row
+ * @return string
+ */
+ public function render(Varien_Object $row)
+ {
+ $actions = $this->getColumn()->getActions();
+ $src = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$row->getImage();
+ return '';
+ }
+}
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Recommendurl.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Recommendurl.php
new file mode 100644
index 00000000..f89b66a4
--- /dev/null
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Recommendurl.php
@@ -0,0 +1,50 @@
+
+ */
+class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Recommendurl
+ extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
+{
+
+ /**
+ * Renders column
+ *
+ * @param Varien_Object $row
+ * @return string
+ */
+ public function render(Varien_Object $row)
+ {
+ $actions = $this->getColumn()->getActions();
+ $url = $row->getUrl().'?re='.$row->getRecommendId();
+ return ''.$this->getColumn()->getHeader().'';
+ }
+}
diff --git a/app/code/local/Martin/Recommend/Block/Adminhtml/Recommend/Grid.php b/app/code/local/Martin/Recommend/Block/Adminhtml/Recommend/Grid.php
index 40544c54..b748bef9 100644
--- a/app/code/local/Martin/Recommend/Block/Adminhtml/Recommend/Grid.php
+++ b/app/code/local/Martin/Recommend/Block/Adminhtml/Recommend/Grid.php
@@ -61,6 +61,12 @@ protected function _prepareColumns()
'index' => 'skus_str'
));
+ $this->addColumn('action', array(
+ 'header' => Mage::helper('adminhtml')->__('View'),
+ 'type' => 'recommend_url',
+ 'index' => 'action'
+ ));
+
return parent::_prepareColumns();
}
public function getGridUrl()
diff --git a/app/code/local/Martin/SalesReports/Block/Adminhtml/Product/Grid.php b/app/code/local/Martin/SalesReports/Block/Adminhtml/Product/Grid.php
index 6e412dbd..40302ee9 100644
--- a/app/code/local/Martin/SalesReports/Block/Adminhtml/Product/Grid.php
+++ b/app/code/local/Martin/SalesReports/Block/Adminhtml/Product/Grid.php
@@ -45,6 +45,7 @@ protected function _prepareCollection()
$collection->getSelect()
->columns("sum(qty_ordered) as num")
->joinLeft('sales_flat_order AS order','main_table.order_id=order.entity_id','')
+ ->joinLeft('catalog_product_entity_varchar as img','main_table.product_id=img.entity_id and img.store_id=0 and img.attribute_id=85',array('image'=>'img.value'))
->where('order.created_at>=?',array('from'=>$from))
->where('order.created_at',array('to'=>$to))
->where("order.status='complete' OR order.status='processing'")
@@ -62,6 +63,12 @@ protected function _prepareColumns()
'header' => Mage::helper('customer')->__('sku'),
'index' => 'sku'
));
+
+ $this->addColumn('image', array(
+ 'header' => Mage::helper('customer')->__('Image'),
+ 'index' => 'image',
+ 'type' => 'image'
+ ));
$this->addColumn('name', array(
'header' => Mage::helper('customer')->__('Name'),