Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.19 KB | None | 0 0
  1. class Easylife_Vendor_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid {
  2.  
  3. public function __construct() {
  4. parent::__construct();
  5. $this->setId('orderGrid');
  6. $this->setDefaultSort('id');
  7. }
  8.  
  9. protected function _prepareCollection() {
  10. $roleId = Mage::helper('vendor')->getConfig('general', 'vendor_role');
  11.  
  12. // $role = Mage::getModel('admin/roles')->load($roleId);
  13.  
  14. $current_user = Mage::getSingleton('admin/session')->getUser();
  15.  
  16. if ($current_user->getRole()->getRoleId() == $roleId) {
  17. $productIds = Mage::getModel('catalog/product')->getCollection()
  18. ->addAttributeToFilter('status', 1)
  19. ->addAttributeToFilter('vendor', $current_user->getId())->getAllIds();
  20.  
  21. $collection = Mage::getResourceModel($this->_getCollectionClass());
  22.  
  23. foreach ($collection as $order) {
  24. foreach ($order->getAllItems() as $item) {
  25. $productId = $item->getData('product_id');
  26. if (in_array($productId, $productIds)) {
  27. Mage::log($order);
  28. Mage::log($order->getDropShipVendor());
  29. $orderIds[] = $order->getId();
  30. break;
  31.  
  32. }
  33. }
  34. }
  35.  
  36. $collection = Mage::getResourceModel($this->_getCollectionClass())
  37. ->addFieldToFilter('entity_id', array('in' => $orderIds));
  38. }
  39. else
  40. $collection = Mage::getResourceModel($this->_getCollectionClass());
  41.  
  42. $this->setCollection($collection);
  43. return parent::_prepareCollection();
  44. }
  45.  
  46. protected function _getCollectionClass() {
  47. return 'sales/order_grid_collection';
  48. }
  49.  
  50. protected function _prepareColumns() {
  51.  
  52. ......
  53.  
  54. return parent::_prepareColumns();
  55. }
  56.  
  57. public function getRowUrl($row) {
  58. return $this->getUrl('*/*/view', array('order_id' => $row->getId()));
  59. }
  60.  
  61. }
  62.  
  63. [item_id] => 57
  64. [order_id] => 45
  65. [parent_item_id] =>
  66. [quote_item_id] => 91
  67. [store_id] => 1
  68. [created_at] => 2014-12-18 10:46:07
  69. [updated_at] => 2014-12-18 10:46:07
  70. [product_id] => 9
  71. [product_type] => simple
  72. [product_options] => a:1:{s:15:"info_buyRequest";a:3:{s:4:"uenc";s:100:"aHR0cDovLzEwLjEwLjEwLjE4NC9tYWdlbnRvbGVhcm5pbmcvaW5kZXgucGhwL2VsZWN0cm9uaWNzL2NlbGwtcGhvbmVzLmh0bWw,";s:7:"product";s:1:"9";s:3:"qty";i:1;}}
  73. [weight] => 1.0000
  74. [is_virtual] => 0
  75. [sku] => 123123
  76. [name] => Iphone 6s
  77. [description] =>
  78. [applied_rule_ids] =>
  79. [additional_data] =>
  80. [free_shipping] => 0
  81. [is_qty_decimal] => 0
  82. [no_discount] => 0
  83. [qty_backordered] =>
  84. [qty_canceled] => 0.0000
  85. [qty_invoiced] => 0.0000
  86. [qty_ordered] => 1.0000
  87. [qty_refunded] => 0.0000
  88. [qty_shipped] => 0.0000
  89. [base_cost] =>
  90. [price] => 30.0000
  91. [base_price] => 30.0000
  92. [original_price] => 30.0000
  93. [base_original_price] => 30.0000
  94. [tax_percent] => 0.0000
  95. [tax_amount] => 0.0000
  96. [base_tax_amount] => 0.0000
  97. [tax_invoiced] => 0.0000
  98. [base_tax_invoiced] => 0.0000
  99. [discount_percent] => 0.0000
  100. [discount_amount] => 0.0000
  101. [base_discount_amount] => 0.0000
  102. [discount_invoiced] => 0.0000
  103. [base_discount_invoiced] => 0.0000
  104. [amount_refunded] => 0.0000
  105. [base_amount_refunded] => 0.0000
  106. [row_total] => 30.0000
  107. [base_row_total] => 30.0000
  108. [row_invoiced] => 0.0000
  109. [base_row_invoiced] => 0.0000
  110. [row_weight] => 1.0000
  111. [base_tax_before_discount] =>
  112. [tax_before_discount] =>
  113. [ext_order_item_id] =>
  114. [locked_do_invoice] =>
  115. [locked_do_ship] =>
  116. [price_incl_tax] => 30.0000
  117. [base_price_incl_tax] => 30.0000
  118. [row_total_incl_tax] => 30.0000
  119. [base_row_total_incl_tax] => 30.0000
  120. [hidden_tax_amount] =>
  121. [base_hidden_tax_amount] =>
  122. [hidden_tax_invoiced] =>
  123. [base_hidden_tax_invoiced] =>
  124. [hidden_tax_refunded] =>
  125. [base_hidden_tax_refunded] =>
  126. [is_nominal] => 0
  127. [tax_canceled] =>
  128. [hidden_tax_canceled] =>
  129. [tax_refunded] =>
  130. [base_tax_refunded] =>
  131. [discount_refunded] =>
  132. [base_discount_refunded] =>
  133. [gift_message_id] =>
  134. [gift_message_available] => 0
  135. [base_weee_tax_applied_amount] => 0.0000
  136. [base_weee_tax_applied_row_amnt] => 0.0000
  137. [base_weee_tax_applied_row_amount] => 0.0000
  138. [weee_tax_applied_amount] => 0.0000
  139. [weee_tax_applied_row_amount] => 0.0000
  140. [weee_tax_applied] => a:0:{}
  141. [weee_tax_disposition] => 0.0000
  142. [weee_tax_row_disposition] => 0.0000
  143. [base_weee_tax_disposition] => 0.0000
  144. [base_weee_tax_row_disposition] => 0.0000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement