1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Customer_Edit_Tab_View_Cart extends Mage_Adminhtml_Block_Widget_Grid
35: {
36:
37: public function __construct()
38: {
39: parent::__construct();
40: $this->setId('customer_view_cart_grid');
41: $this->setDefaultSort('added_at', 'desc');
42: $this->setSortable(false);
43: $this->setPagerVisibility(false);
44: $this->setFilterVisibility(false);
45: $this->setEmptyText(Mage::helper('customer')->__('There are no items in customer\'s shopping cart at the moment'));
46: }
47:
48: protected function _prepareCollection()
49: {
50: $quote = Mage::getModel('sales/quote');
51:
52: if ($this->getWebsiteId()) {
53: $quote->setWebsite(Mage::app()->getWebsite($this->getWebsiteId()));
54: }
55: $quote->loadByCustomer(Mage::registry('current_customer'));
56:
57: if ($quote) {
58: $collection = $quote->getItemsCollection(false);
59: }
60: else {
61: $collection = new Varien_Data_Collection();
62: }
63:
64: $collection->addFieldToFilter('parent_item_id', array('null' => true));
65: $this->setCollection($collection);
66:
67: return parent::_prepareCollection();
68: }
69:
70: protected function _prepareColumns()
71: {
72: $this->addColumn('product_id', array(
73: 'header' => Mage::helper('customer')->__('Product ID'),
74: 'index' => 'product_id',
75: 'width' => '100px',
76: ));
77:
78: $this->addColumn('name', array(
79: 'header' => Mage::helper('customer')->__('Product Name'),
80: 'index' => 'name',
81: ));
82:
83: $this->addColumn('sku', array(
84: 'header' => Mage::helper('customer')->__('SKU'),
85: 'index' => 'sku',
86: 'width' => '100px',
87: ));
88:
89: $this->addColumn('qty', array(
90: 'header' => Mage::helper('customer')->__('Qty'),
91: 'index' => 'qty',
92: 'type' => 'number',
93: 'width' => '60px',
94: ));
95:
96: $this->addColumn('price', array(
97: 'header' => Mage::helper('customer')->__('Price'),
98: 'index' => 'price',
99: 'type' => 'currency',
100: 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
101: ));
102:
103: $this->addColumn('total', array(
104: 'header' => Mage::helper('customer')->__('Total'),
105: 'index' => 'row_total',
106: 'type' => 'currency',
107: 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
108: ));
109:
110: return parent::_prepareColumns();
111: }
112:
113: public function getRowUrl($row)
114: {
115: return $this->getUrl('*/catalog_product/edit', array('id' => $row->getProductId()));
116: }
117:
118: public function ()
119: {
120: return ($this->getCollection()->getSize() > 0);
121: }
122:
123: }
124: