Try this,
Inject this in your constructor
<?php
namespace Vendor\Module\Controller\Orders;
class SetOrders extends \Magento\Framework\App\Action\Action
{
protected $resultPageFactory;
protected $itemFactory;
public function __construct(
\Magento\Sales\Model\Order\ItemFactory $itemFactory,
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory
) {
and add this in your constructor
$this->itemFactory = $itemFactory;
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
then you can apply filter like this anywhere in your function and in your case it would be like
public function executegetAllItems()
{
try {
$current_seller_id = 5;
$order = $this->itemFactory->create()->getCollection()->addFieldToFilter('current_seller_id', $current_seller_id);
foreach ($order as $items) {
echo $itemId = $items->getItemId();
}
echo "success";
} catch (\Exception $e) {
error_log($e->getMessage());
}
}
}
this is how you can add filter by your attribute.
Hope this helps :)