enter image description here

This snapshot of order detail page. I Just want to known that which file or function call for setting this collection in this page. I want to just get Selected (Filter Row) Items Order.

2 Answers 2


Check the assigned block to render the order items defined in layout file vendor\magento\module-sales\view\adminhtml\layout\sales_order_view.xml

<block class="Magento\Sales\Block\Adminhtml\Order\View\Items" name="order_items" template="Magento_Sales::order/view/items.phtml">

Block method \Magento\Sales\Block\Adminhtml\Order\View\Items::getItemsCollection() responsible for serving order item data to this page template.

You can get an idea to filter order item data on that collection in order model:

\Magento\Sales\Model\Sales::getItemsCollection($filterByTypes = [], $nonChildrenOnly = false);

  • MageAj ? You say absolute right Block method \Magento\Sales\Block\Adminhtml\Order\View\Items::getItemsCollection() is responsible for Items Collection. I override this block. i change the function public function getItemsCollection() { return $this->getOrder()->getItemsCollection()->addFieldToFilter('current_seller_id',array('eq'=>1)); } it return the same result. don't filter the collection. same result as i mention snapshoot in Question. in sales_order_item a custom_attribute is save named "current_seller_id" and has value 1 But is not filter the result kindly check
    – HaFiz Umer
    Feb 24, 2019 at 19:03
  • Dear MageAj ! I did it by this public function getItemsCollection() { //return $this->getOrder()->getItemsCollection(); $Items_order=$this->getOrder()->getItemsCollection(); $filter_order_items=[]; foreach ($Items_order as $Items) { if($Items["current_seller_id"]==1){ $filter_order_items[]=$Items; } } return $filter_order_items; } It filter absolute right. But i don't why addFieldToFilter('current_seller_id',array('eq'=>1)); don't know work. foreach loop work perfectly
    – HaFiz Umer
    Feb 24, 2019 at 19:39

Is the method for getting items for section,If you want to MOdify that item collection then you have to work on that method

  • Yes it function responsible for items collection. But when i apply filter, it not filter the collection. I Have column named "current_saller_id" in sales_order_item. Check it why not apply filter. public function getItemsCollection() { return $this->getOrder()->getItemsCollection()->addFieldToFilter('current_seller_id',array('eq'=>1)); }
    – HaFiz Umer
    Feb 24, 2019 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.