Skip to content

Commit

Permalink
201805101046
Browse files Browse the repository at this point in the history
  • Loading branch information
adam ling committed May 10, 2018
1 parent f530805 commit 5df032b
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Grid column widget for rendering action grid cells
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <[email protected]>
*/
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 '<img width="80" height="80" src="'.$src.'" />';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magento.com for more information.
*
* @category Mage
* @package Mage_Adminhtml
* @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/**
* Grid column widget for rendering action grid cells
*
* @category Mage
* @package Mage_Adminhtml
* @author Magento Core Team <[email protected]>
*/
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 '<a target="_blank" href="'.$url.'">'.$this->getColumn()->getHeader().'</a>';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'")
Expand All @@ -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'),
Expand Down

0 comments on commit 5df032b

Please sign in to comment.