public function options()
 {
     $options = Client::getCollection($this->fields->options->resource, 'SkuOption');
     foreach ($options as $option) {
         $option->product_id = $this->product_id;
     }
     return $options;
 }
Beispiel #2
0
 public function conditions()
 {
     $conditions = Client::getCollection($this->fields->conditions->resource, 'RuleCondition');
     foreach ($conditions as $condition) {
         $condition->product_id = $this->product_id;
     }
     return $conditions;
 }
Beispiel #3
0
 protected static function getCachedCollection($endpoint, $force)
 {
     $cacheKey = 'bigcommerce' . str_replace('/', '.', $endpoint);
     $cached = $force ? null : Cache::get($cacheKey);
     if ($cached === null) {
         $cached = Bigcommerce::getCollection($endpoint);
         if ($cached !== null) {
             Cache::forever($cacheKey, $cached);
         }
     }
     return $cached;
 }
 /**
  * Fetch a paginated set of Bigcommerce objects and store them
  *
  * @return void
  */
 public function handle()
 {
     try {
         $objects = Bigcommerce::getCollection("/{$this->resource}" . '?' . http_build_query(['page' => $this->page, 'limit' => $this->page_size]));
     } catch (Exception $e) {
         Log::error("Error while fetching {$this->resource}, page: {$this->page}, limit: {$this->page_size} from Bigcommerce.");
         Log::error($e->getMessage());
         return;
     }
     $class_name = $this->model_class_name;
     foreach ($objects as $bc_object) {
         $model = $class_name::firstOrNew(['id' => $bc_object->id]);
         $model->fill($model->mapData($bc_object));
         $model->save();
     }
 }
 public function values()
 {
     return Client::getCollection($this->fields->values->resource, 'OptionValue');
 }
 public function addresses()
 {
     return Client::getCollection($this->fields->addresses->resource, 'Address');
 }
 public function options()
 {
     return Client::getCollection('/products/' . $this->id . '/options', 'ProductOption');
 }
 public function testGetCollectionReturnsCollectionOfSpecifiedTypes()
 {
     $this->connection->expects($this->once())->method('get')->with('http://storeurl' . $this->basePath . '/whatever', false)->will($this->returnValue(array(array(), array())));
     Client::configure(array('store_url' => 'http://storeurl', 'username' => 'whatever', 'api_key' => 'whatever'));
     Client::setConnection($this->connection);
     // re-set the connection since Client::configure unsets it
     $resources = Client::getCollection('/whatever');
     $this->assertInternalType('array', $resources);
     foreach ($resources as $resource) {
         $this->assertInstanceOf('Bigcommerce\\Api\\Resource', $resource);
     }
 }
 public function options()
 {
     return Client::getCollection($this->fields->options->resource, 'OptionSetOption');
 }
 public function coupons()
 {
     return Client::getCollection($this->fields->coupons->resource, 'Coupon');
 }