Ejemplo n.º 1
0
 /**
  * Returns Ebay last passed orders as an array of EbayOrder objects
  *
  * @param string $until_date Date until which the orders should be retrieved
  * @return array
  **/
 private function _getEbayLastOrders($until_date)
 {
     $nb_days_backward = (int) Configuration::get('EBAY_ORDERS_DAYS_BACKWARD');
     if (Configuration::get('EBAY_INSTALL_DATE') < date('Y-m-d\\TH:i:s', strtotime('-' . $nb_days_backward . ' days'))) {
         //If it is more than 30 days that we installed the module
         // check from 30 days before
         $from_date_ar = explode('T', $this->ebay_profile->getConfiguration('EBAY_ORDER_LAST_UPDATE'));
         $from_date = date('Y-m-d', strtotime($from_date_ar[0] . ' -30 day'));
         $from_date .= 'T' . (isset($from_date_ar[1]) ? $from_date_ar[1] : '');
     } else {
         //If it is less than 30 days that we installed the module
         // check from one day before
         $from_date_ar = explode('T', Configuration::get('EBAY_INSTALL_DATE'));
         $from_date = date('Y-m-d', strtotime($from_date_ar[0] . ' -1 day'));
         $from_date .= 'T' . (isset($from_date_ar[1]) ? $from_date_ar[1] : '');
     }
     $ebay = new EbayRequest();
     $page = 1;
     $orders = array();
     $nb_page_orders = 100;
     while ($nb_page_orders > 0 && $page < 10) {
         $page_orders = array();
         foreach ($ebay->getOrders($from_date, $until_date, $page) as $order_xml) {
             $page_orders[] = new EbayOrder($order_xml);
         }
         $nb_page_orders = count($page_orders);
         $orders = array_merge($orders, $page_orders);
         $page++;
     }
     return $orders;
 }