コード例 #1
0
 /**
  * Synchronization categories from ebay
  * @param int $site_id
  * @param int $category_id
  * @throws \Exception
  */
 public static function synchronization($site_id, $category_id)
 {
     $client = Client::instance();
     $client->setSiteId($site_id);
     $features_list = array('PayPalRequired', 'VariationsEnabled', 'MinimumReservePrice', 'ReturnPolicyEnabled', 'PaymentMethods', 'StoreInventoryEnabled', 'ListingDurations', 'ConditionEnabled', 'ConditionValues', 'HandlingTimeEnabled', 'StoreOwnerExtendedListingDurations');
     $result = $client->getCategoryFeatures($category_id, $features_list);
     if ($result) {
         if (!$result->isSuccess()) {
             throw new \Exception(implode("\n", $result->getErrorMessages()));
         }
         $features = array('payment_methods' => $result->getPaymentMethods(), 'paypal_required' => $result->isPayPalRequired(), 'condition_enabled' => $result->isConditionEnabled(), 'conditions' => $result->getConditions(), 'listing_duration' => $result->getListingDurations('FixedPriceItem'));
         $data = array('features' => json_encode($features), 'feature_update_time' => time());
         Category::update($site_id, $category_id, $data);
     } else {
         throw new \Exception(implode("\n", $client->getErrors()));
     }
 }
コード例 #2
0
ファイル: Category.php プロジェクト: ambient-lounge/site
 /**
  * Synchronization categories from ebay
  * @param int $site_id
  * @throws \Exception
  */
 public static function synchronization($site_id)
 {
     $client = Client::instance();
     $client->setSiteId($site_id);
     $result = $client->getCategories();
     if ($result) {
         if (!$result->isSuccess()) {
             throw new \Exception(implode("\n", $result->getErrorMessages()));
         }
         $category_version = $result->getCategoryVersion();
     } else {
         throw new \Exception(implode("\n", $client->getErrors()));
     }
     $versions = static::getCategoryVersions();
     if (empty($versions[$site_id]) || $versions[$site_id] != $category_version) {
         $result = $client->getCategories(array(), null, 'ReturnAll');
         if ($result) {
             if (!$result->isSuccess()) {
                 throw new \Exception(implode("\n", $result->getErrorMessages()));
             }
             $categories = $result->getCategories();
             $data = array();
             foreach ($categories as $item) {
                 $path = $item['CategoryParentIds'];
                 $path[] = $item['CategoryID'];
                 $data[] = array('category_id' => $item['CategoryID'], 'parent_id' => $item['CategoryParentID'], 'leaf' => $item['LeafCategory'] ? 'Y' : 'N', 'name' => $item['CategoryName'], 'level' => $item['CategoryLevel'], 'id_path' => implode(',', $path), 'full_name' => implode(' > ', $item['CategoryNames']), 'site_id' => $site_id, 'features' => '');
             }
             db_query('DELETE FROM ?:ebay_categories WHERE site_id = ?i', $site_id);
             $limit = 60;
             $part_count = (int) ceil(count($data) / $limit);
             for ($i = 0; $i < $part_count; $i++) {
                 $part_data = array_slice($data, $limit * $i, $limit);
                 db_query('INSERT INTO ?:ebay_categories ?m', $part_data);
             }
             static::setCategoryVersion($site_id, $category_version);
             static::setLastSynchronizationTime($site_id, time());
         } else {
             throw new \Exception(implode("\n", $client->getErrors()));
         }
     } elseif ($versions[$site_id] == $category_version) {
         static::setLastSynchronizationTime($site_id, time());
     }
 }
コード例 #3
0
ファイル: Site.php プロジェクト: ambient-lounge/site
 /**
  * Update sites from ebay
  * @throws \Exception
  */
 public static function synchronization()
 {
     $client = Client::instance();
     $result = $client->getEbayDetails('SiteDetails');
     if ($result) {
         if (!$result->isSuccess()) {
             throw new \Exception(implode("\n", $result->getErrorMessages()));
         }
         $sites = $result->getSiteDetails();
         if (!empty($sites)) {
             $data = array();
             foreach ($sites as $item) {
                 $data[] = array('site_id' => $item->site_id, 'site' => $item->site);
             }
             db_query('DELETE FROM ?:ebay_sites WHERE 1');
             db_query('INSERT INTO ?:ebay_sites ?m', $data);
             static::setLastSynchronizationTime(time());
         }
     } else {
         throw new \Exception(implode("\n", $client->getErrors()));
     }
 }
コード例 #4
0
ファイル: Shipping.php プロジェクト: ambient-lounge/site
 /**
  * Synchronization shipping services from ebay
  * @param int $site_id
  * @throws \Exception
  */
 public static function synchronization($site_id)
 {
     $client = Client::instance();
     $client->setSiteId($site_id);
     $result = $client->getEbayDetails('ShippingServiceDetails');
     if ($result) {
         if (!$result->isSuccess()) {
             throw new \Exception(implode("\n", $result->getErrorMessages()));
         }
         $services = $result->getShippingServiceDetails();
         $data = array();
         foreach ($services as $item) {
             if ($item->valid_for_selling_flow) {
                 $data[] = array('service_id' => $item->shipping_service_id, 'name' => $item->shipping_service, 'description' => $item->description, 'service_type' => implode(',', $item->service_type), 'is_international' => $item->international_service ? 'Y' : 'N', 'category' => $item->shipping_category, 'ship_days_max' => $item->shipping_time_max, 'ship_days_min' => $item->shipping_time_min, 'package' => implode(',', $item->shipping_package), 'carrier' => implode(',', $item->shipping_carrier), 'weight_required' => $item->weight_required ? 'Y' : 'N', 'selling_flow' => 'Y', 'dimensions_required' => $item->dimensions_required ? 'Y' : 'N', 'surcharge_applicable' => $item->surcharge_applicable ? 'Y' : 'N', 'expedited_service' => $item->expedited_service ? 'Y' : 'N', 'detail_version' => $item->detail_version, 'update_timestamp' => $item->update_time, 'site_id' => $site_id);
             }
         }
         db_query('DELETE FROM ?:ebay_shippings WHERE site_id = ?i', $site_id);
         db_query('INSERT INTO ?:ebay_shippings ?m', $data);
         static::setLastSynchronizationTime($site_id, time());
     } else {
         throw new \Exception(implode("\n", $client->getErrors()));
     }
 }
コード例 #5
0
ファイル: Controller.php プロジェクト: ambient-lounge/site
 /**
  * @param Product|Product[] $product
  * @param Client $api
  * @param int $action
  */
 protected static function checkInternalErrors($product, Client $api, $action)
 {
     $products = array();
     if ($product instanceof Product) {
         $products = array($product);
     } elseif (is_array($product)) {
         $products = $product;
     }
     $errors = $api->getErrors();
     foreach ($errors as $error) {
         $code = crc32($error);
         static::setError($code, $error);
         foreach ($products as $product) {
             if ($product instanceof Product) {
                 ProductLogger::error($action, $product, $error, $code);
             }
         }
     }
 }