Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get Products
- function GetProducts($cache = true) {
- $response = Bigcommerce_api::communicate( 'products/count', $cache );
- // Handle Lack Of Response
- if( ! $response || empty( $response ) ) { return false; }
- $number_of_products_obj = Bigcommerce_parser::XmlToObject( $response, 'number_of_products' );
- $number_of_products = $number_of_products_obj->count->__toString();
- $number_of_pages = intval($number_of_products/50)+ 1;
- $all_products = array();
- for ($ndx=1; $ndx<=$number_of_pages; $ndx++) {
- $products = array();
- // Query Bigcommerce API
- $query_vars = array( 'page' => $ndx);
- $response = self::communicate( 'products?' . http_build_query($query_vars), $cache );
- // Handle Lack Of Response
- if( ! $response || empty( $response ) ) { return false; }
- $products = Bigcommerce_parser::XmlToObject( $response, 'product' );
- foreach( $products as $product ) {
- array_push($all_products,$product);
- }
- }
- return $all_products;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement