function product($num) { printName('Product'); $product = Bigcommerce::getProduct($num); echo $product->name . '<br>'; echo $product->price . '<br><br>'; }
public function setUp() { $methods = array('useXml', 'failOnError', 'authenticate', 'setTimeout', 'useProxy', 'verifyPeer', 'addHeader', 'getLastError', 'get', 'post', 'head', 'put', 'delete', 'getStatus', 'getStatusMessage', 'getBody', 'getHeader', 'getHeaders', '__destruct'); $this->connection = $this->getMockBuilder('Bigcommerce\\Api\\Connection')->disableOriginalConstructor()->setMethods($methods)->getMock(); $this->basePath = $this->getStaticAttribute('Bigcommerce\\Api\\Client', 'api_path'); Client::setConnection($this->connection); }
public function update() { $order = new \stdClass(); // to use stdClass in global namespace use this... $order->status_id = $this->status_id; $order->is_deleted = $this->is_deleted; Client::updateResource('/orders/' . $this->id, $order); }
/** * Bootstrap the application events. * * @return void */ public function boot() { $this->package('kalley/laravel-bigcommerce'); $store_url = $this->config('store_url'); $username = $this->config('username'); $api_key = $this->config('api_key'); Bigcommerce::configure(['store_url' => $store_url, 'username' => $username, 'api_key' => $api_key]); }
/** * 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 delete() { Client::deleteResource('/products/' . $this->fields->product_id . '/customfields/' . $this->id); }
public function tax_class() { return Client::getResource($this->fields->tax_class->resource, 'TaxClass'); }
/** * Delete the given option set. * * @param int $id option id * @return mixed */ public static function deleteOptionSet($id) { Client::deleteResource('/optionsets/' . $id); }
/** * Dispatch resources refresh jobs for a base resource - i.e. one not dependent on another resource ID. * * @param String $resource The name of the resource to refresh * @return void */ protected function dispatchResourceRefresh($resource) { $page_size = $this->page_size; $resource_count = Bigcommerce::getCount("/{$resource}/count"); $this->info("{$resource_count} objects"); $this->info("{$page_size} page size"); $this->info(floor($resource_count / $page_size) + 1 . " pages to dispatch"); $page = 1; $paging_resource_count = $resource_count; while ($paging_resource_count > 0) { $this->dispatcher->dispatch(new ResourceCacheJob($page, $resource)); $paging_resource_count -= $page_size; $page++; } $this->info("Dispatched " . ($page - 1) . " pages of {$resource} refresh commands"); }
public function update() { Client::updateResource('/options/' . $this->fields->option_id . '/values/' . $this->id, $this->getUpdateFields()); }
public function option() { return Client::getResource('/options/' . $this->fields->option_id, 'Option'); }
public function update() { return Client::updateResource('/orders/' . $this->fields->order_id . '/shipments/' . $this->id, $this->getUpdateFields()); }
public function testGettingOrderShippingAddressesReturnsTheAddressResource() { $this->connection->expects($this->once())->method('get')->with($this->basePath . '/orders/1/shipping_addresses', false)->will($this->returnValue(array(array(), array()))); $collection = Client::getOrderShippingAddresses(1); $this->assertInternalType('array', $collection); foreach ($collection as $resource) { $this->assertInstanceOf('Bigcommerce\\Api\\Resources\\Address', $resource); } }
Bigcommerce::verifyPeer(false); Bigcommerce::setCipher('RC4-SHA'); $num_of_products = Bigcommerce::getProductsCount(); if ($num_of_products <= 250) { $max_pages = 1; } else { $pages_double = $num_of_products / 250; $pages_int = (int) ($num_of_products / 250); if ($pages_double > $pages_int) { $max_pages = $pages_int + 1; } else { $max_pages = $pages_int; //If 250 goes into number of products evenly (rare) } } $fields = array('related_products' => '-1'); $processed = array(); //Collection returns duplicates sometimes, this will hold the ID of all products we processed. $current_page = 1; while ($current_page <= $max_pages) { $filter = array('page' => $current_page, 'limit' => 250); $products = Bigcommerce::getProducts($filter); foreach ($products as $product) { $id = $product->id; if (!in_array($id, $processed)) { Bigcommerce::updateProduct($id, $fields); array_push($processed, $id); } } ++$current_page; }
public function values() { return Client::getCollection($this->fields->values->resource, 'OptionValue'); }
public static function getCountryState($country_id, $id) { return Bigcommerce::getResource('/countries/' . $country_id . '/states/' . $id); }
public function update() { Client::updateResource('/products/' . $this->fields->product_id . '/rules/' . $this->fields->id, $this->getUpdateFields()); }
public function update() { return Client::updateCategory($this->id, $this->getUpdateFields()); }
public function update() { Client::updateResource('/optionsets/options/' . $this->id, $this->getUpdateFields()); }
public function delete() { return Client::deleteCustomer($this->id); }
} else { $pages_double = $num_of_products / 250; $pages_int = (int) ($num_of_products / 250); if ($pages_double > $pages_int) { $max_pages = $pages_int + 1; } else { $max_pages = $pages_int; //If 250 goes into number of products evenly (rare) } } $processed = array(); //Collection returns duplicates sometimes, this will hold the ID of all products we processed. $file = './output.txt'; $fp = fopen($file, 'wb'); $current_page = 1; while ($current_page <= $max_pages) { $filter = array('page' => $current_page, 'limit' => 250); $products = Bigcommerce::getProducts($filter); foreach ($products as $product) { $id = $product->id; if (!in_array($id, $processed)) { if ($product->availability_description != NULL) { fwrite($fp, $product->name); fwrite($fp, "\n----------\n"); break; } array_push($processed, $id); } } ++$current_page; }