I want to generate PDF of selected orders, Rest of the functionality is complete just wanted to get selected Ids from sales order grid. For now I am getting full list of Orders on clicking my custom action. I am passing Order collection to controller action from custom block. This is what I wanted to get in block:
My Block Class is:
class Order extends \Magento\Framework\View\Element\Template {
public function __construct(\Magento\Framework\View\Element\Template\Context $context,
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
\Magento\Sales\Model\OrderRepository $orderRepository
..........
array $data = []
) {
.....
parent::__construct($context, $data);
}
public function getOrders() {
//$ids = '24,23,21,16';
$orderCollection = $this->_orderCollectionFactory->create()->addFieldToSelect('*');
//$orderCollection = $orderCollection->addFieldToFilter('entity_id', ['in' => $ids]);
return $orderCollection;
}
And Controller is: use VendorName\ModuleName\Block\Order;
class CreatePdf extends \Magento\Backend\App\Action {
public function __construct(Context $context,Order $order, DirectoryList $dir, PageFactory $resultPageFactory)
{
parent::__construct($context);
}
public function execute() {
//Custom Logic
}
I followed this link but it is not working, https://stackoverflow.com/questions/24884544/how-can-i-get-the-selected-order-ids-in-custom-action-in-sales-order-on-click
Thanks