protected function _checkCDShipments() { $resource = Mage::getSingleton('core/resource'); $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->addFieldToFilter('main_table.is_final', array('eq' => '0')); $collection->addFieldToFilter('shipping_address.country_id', array('nin' => array($this->helper->whiteListCodes()))); $collection->addFieldToFilter('main_table.created_at', array('gt' => date('Y-m-d', strtotime('-2 months')))); $this->_checkCollectionStatus($collection); }
/** * Adds Magento tracking information to the order containing the previously retrieved barcode. * * @param string $trackAndTraceCode * * @return $this * * @throws TIG_MyParcel2014_Exception */ public function addTrackingCodeToShipment($trackAndTraceCode) { $shipment = $this->getShipment(); if (!$shipment || !$trackAndTraceCode) { throw new TIG_MyParcel2014_Exception($this->helper->__('Unable to add tracking info: no track&trace code or shipment available.'), 'MYPA-0013'); } $carrierCode = self::MYPARCEL_CARRIER_CODE; $carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/name', $shipment->getStoreId()); $data = array('carrier_code' => $carrierCode, 'title' => $carrierTitle, 'number' => $trackAndTraceCode); /** * @var Mage_Sales_Model_Order_Shipment_Track $track */ $track = Mage::getModel('sales/order_shipment_track')->addData($data); $shipment->addTrack($track); /** * Save the Mage_Sales_Order_Shipment object * * @var Mage_Core_Model_Resource_Transaction $transaction */ $transaction = Mage::getModel('core/resource_transaction'); $transaction->addObject($shipment)->save(); return $this; }