If I want to get data from sales_order_grid table, which CollectionFactory I should inject?
for example: If I want to get Sales_order_item, I should use
\Magento\Sales\Model\ResourceModel\Order\Item\CollectionFactory $itemCollectionFactory,
so If I want get data from sales_order_grid, which CollectionFactory I should use?
IS there any documentation I can learn the difference of those different Collection Factory? Thanks
I just showing my code below, but I have no idea why magento saying "has an error: Call to undefined method Magento\Sales\Model\ResourceModel\Order\Grid\Collection\Interceptor::create(). [] [] "
use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as SalesOrderGridCollection;
/**
* @var SalesOrderGridCollection
*/
private $sOGcollection;
public function __construct(
SalesOrderGridCollection $sOGcollection
) {
$this->sOGcollection = $sOGcollection;
public function getSalesOrderGrid()
{
try {
$itemData = $this->sOGcollection->create();
$currentDate = date("Y-m-d H:i:s"); // Y-m-d h:i:s
$newDate = strtotime('-30 MINUTE', strtotime($currentDate));
$newDate = date('Y-m-d H:i:s', $newDate);
$itemData->addFieldToFilter('updated_at', ['gteq' => $newDate]);
$itemData->addFieldToFilter('updated_at', ['lteq' => $currentDate]);
$itemData->load();
return $itemData;
} catch (LocalizedException $e) {
$this->logger->error($e->getMessage());
}
return null;
}
$SalesOrderGride = $this->getSalesOrderGrid();