00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Cart extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('customer_view_cart_grid');
00041 $this->setDefaultSort('added_at', 'desc');
00042 $this->setSortable(false);
00043 $this->setPagerVisibility(false);
00044 $this->setFilterVisibility(false);
00045 $this->setEmptyText(Mage::helper('customer')->__('There are no items in customer\'s shopping cart at the moment'));
00046 }
00047
00048 protected function _prepareCollection()
00049 {
00050 $quote = Mage::getModel('sales/quote');
00051
00052 if ($this->getWebsiteId()) {
00053 $quote->setWebsite(Mage::app()->getWebsite($this->getWebsiteId()));
00054 }
00055 $quote->loadByCustomer(Mage::registry('current_customer'));
00056
00057 if ($quote) {
00058 $collection = $quote->getItemsCollection(false);
00059 }
00060 else {
00061 $collection = new Varien_Data_Collection();
00062 }
00063 $this->setCollection($collection);
00064
00065 return parent::_prepareCollection();
00066 }
00067
00068 protected function _prepareColumns()
00069 {
00070 $this->addColumn('product_id', array(
00071 'header' => Mage::helper('customer')->__('Product ID'),
00072 'index' => 'product_id',
00073 'width' => '100px',
00074 ));
00075
00076 $this->addColumn('name', array(
00077 'header' => Mage::helper('customer')->__('Product Name'),
00078 'index' => 'name',
00079 ));
00080
00081 $this->addColumn('sku', array(
00082 'header' => Mage::helper('customer')->__('SKU'),
00083 'index' => 'sku',
00084 'width' => '100px',
00085 ));
00086
00087 $this->addColumn('qty', array(
00088 'header' => Mage::helper('customer')->__('Qty'),
00089 'index' => 'qty',
00090 'type' => 'number',
00091 'width' => '60px',
00092 ));
00093
00094 $this->addColumn('price', array(
00095 'header' => Mage::helper('customer')->__('Price'),
00096 'index' => 'price',
00097 'type' => 'currency',
00098 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
00099 ));
00100
00101 $this->addColumn('total', array(
00102 'header' => Mage::helper('customer')->__('Total'),
00103 'index' => 'row_total',
00104 'type' => 'currency',
00105 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
00106 ));
00107
00108 return parent::_prepareColumns();
00109 }
00110
00111 public function getRowUrl($row)
00112 {
00113 return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
00114 }
00115
00116 public function getHeadersVisibility()
00117 {
00118 return ($this->getCollection()->getSize() > 0);
00119 }
00120
00121 }