ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace JR\NetSuite\Model\ResourceModel\ProductQueue;
|
||||
|
||||
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
|
||||
use JR\NetSuite\Model\Data\ProductQueueItem;
|
||||
use JR\NetSuite\Model\ResourceModel\ProductQueue as ProductQueueResource;
|
||||
|
||||
class Collection extends AbstractCollection
|
||||
{
|
||||
protected function _construct()
|
||||
{
|
||||
$this->_init(ProductQueueItem::class, ProductQueueResource::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get next items in the queue based on batch size
|
||||
*
|
||||
* @param int $type_id
|
||||
* @param int $batchSize
|
||||
* @return \Magento\Framework\Data\Collection\AbstractDb
|
||||
*/
|
||||
public function getNext($batchSize = null)
|
||||
{
|
||||
$collection = $this
|
||||
->addFieldToSelect('*')
|
||||
->addFieldToFilter('status', ['eq' => 'pending'])
|
||||
->setOrder('id', 'asc');
|
||||
|
||||
if ($batchSize) {
|
||||
$collection->getSelect()->limit($batchSize);
|
||||
}
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
// Custom methods to add more specialized filters
|
||||
public function addStatusFilter($status)
|
||||
{
|
||||
$this->addFieldToFilter('status', $status);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addDateRangeFilter($fromDate, $toDate)
|
||||
{
|
||||
$this->addFieldToFilter('updated_at', ['from' => $fromDate, 'to' => $toDate]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addUnprocessedFilter()
|
||||
{
|
||||
$this->addFieldToFilter('status', ['neq' => 'processed']);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addPendingFilter()
|
||||
{
|
||||
$this->addFieldToFilter('status', ['eq' => 'pending']);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addProcessingFilter()
|
||||
{
|
||||
$this->addFieldToFilter('status', ['eq' => 'processing']);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addFailedFilter()
|
||||
{
|
||||
$this->addFieldToFilter('status', ['eq' => 'failed']);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addProcessedFilter()
|
||||
{
|
||||
$this->addFieldToFilter('status', ['eq' => 'processed']);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addUpdatedAtFilter($fromDate, $toDate)
|
||||
{
|
||||
$this->addFieldToFilter('updated_at', ['from' => $fromDate, 'to' => $toDate]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addCreatedAtFilter($fromDate, $toDate)
|
||||
{
|
||||
$this->addFieldToFilter('created_at', ['from' => $fromDate, 'to' => $toDate]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addNetsuiteProductIdFilter($netsuiteProductId)
|
||||
{
|
||||
$this->addFieldToFilter('netsuite_product_id', $netsuiteProductId);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addSkuFilter($sku)
|
||||
{
|
||||
$this->addFieldToFilter('sku', $sku);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addTypeFilter($type)
|
||||
{
|
||||
$this->addFieldToFilter('type', $type);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all product queue items that are pending
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getPendingItems()
|
||||
{
|
||||
return $this->addPendingFilter();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user