diff --git a/app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php b/app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php index d54e4aa0..1aa13a51 100755 --- a/app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php +++ b/app/code/community/TIG/MyParcel2014/Model/Api/MyParcel.php @@ -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)) { @@ -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; - } /** diff --git a/app/code/community/TIG/MyParcel2014/Model/Observer/Cron.php b/app/code/community/TIG/MyParcel2014/Model/Observer/Cron.php index 7d5fcb33..2c12f0a9 100755 --- a/app/code/community/TIG/MyParcel2014/Model/Observer/Cron.php +++ b/app/code/community/TIG/MyParcel2014/Model/Observer/Cron.php @@ -65,12 +65,18 @@ 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())) @@ -78,7 +84,8 @@ protected function _checkEUShipments() $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); } @@ -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){