Skip to content

Commit

Permalink
Merge pull request #476 from myparcelnl/fix-status-update-max-800
Browse files Browse the repository at this point in the history
add a limit for status update
  • Loading branch information
RichardPerdaan authored Sep 4, 2019
2 parents e606b6b + da089aa commit f729da3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
16 changes: 6 additions & 10 deletions app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,14 @@ public function createConsignmentRequest(TIG_MyParcel2014_Model_Shipment $myParc
* @param array $consignmentIds
*
* @return array $responseShipments|false
* @throws \TIG_MyParcel2014_Exception
*/
public function getConsignmentsInfoData($consignmentIds = array()){

if($consignmentIds){

$apiInfo = Mage::getModel('tig_myparcel/api_myParcel');
$responseData = $apiInfo->createConsignmentsInfoRequest($consignmentIds)
/** @var \TIG_MyParcel2014_Model_Api_MyParcel $apiInfo */
$responseData = $this->createConsignmentsInfoRequest($consignmentIds)
->sendRequest('GET')
->getRequestResponse();

$responseData = json_decode($responseData);

if (!key_exists('data', (array)$responseData)) {
Expand All @@ -501,17 +499,15 @@ public function getConsignmentsInfoData($consignmentIds = array()){
/**
* @param array $consignmentIds
*
* @return $this
* @return self
*/
public function createConsignmentsInfoRequest($consignmentIds = array()){

public function createConsignmentsInfoRequest($consignmentIds = array()){

$requestString = '/' . implode(';',$consignmentIds) . '?size=300';
$requestString = '/' . implode(';',$consignmentIds) . '?size=800';

$this->_setRequestParameters($requestString, self::REQUEST_TYPE_CREATE_CONSIGNMENT, self::REQUEST_HEADER_SHIPMENT);

return $this;

}

/**
Expand Down
21 changes: 14 additions & 7 deletions app/code/community/TIG/MyParcel2014/Model/Observer/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,27 @@ public function checkStatus()
protected function _checkEUShipments()
{
$resource = Mage::getSingleton('core/resource');
/** @var TIG_MyParcel2014_Model_Resource_Shipment_Collection $collection */
$collection = Mage::getResourceModel('tig_myparcel/shipment_collection');

$collection->getSelect()->joinLeft(
array('shipping_address' => $resource->getTableName('sales/order_address')),
"main_table.entity_id=shipping_address.parent_id AND shipping_address.address_type='shipping'",
array());
$collection->getSelect()
->limit(800)
->joinLeft(
array(
'shipping_address' => $resource->getTableName('sales/order_address')
),
"main_table.entity_id=shipping_address.parent_id AND shipping_address.address_type='shipping'",
array()
);

$collection->addFieldToFilter('shipping_address.country_id', array(
'in' => array($this->helper->whiteListCodes()))
);
$collection->addFieldToFilter('main_table.is_final', array('eq' => '0'));
$collection->addFieldToFilter('main_table.created_at', array(
'gt' => date('Y-m-d', strtotime('-21 day')))
);
)
->setOrder('main_table.created_at', 'DESC');

$this->_checkCollectionStatus($collection);
}
Expand Down Expand Up @@ -128,8 +135,8 @@ protected function _checkCollectionStatus($collection)
}
}


$apiInfo = Mage::getModel('tig_myparcel/api_myParcel');
/** @var \TIG_MyParcel2014_Model_Api_MyParcel $apiInfo */
$apiInfo = Mage::getModel('tig_myparcel/api_myParcel');
$responseShipments = $apiInfo->getConsignmentsInfoData($consignmentIds);

if($responseShipments){
Expand Down

0 comments on commit f729da3

Please sign in to comment.