Advertisement
collincondray

Untitled

Apr 2nd, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. // Get Products
  2. function GetProducts($cache = true) {
  3.  
  4. $response = Bigcommerce_api::communicate( 'products/count', $cache );
  5.  
  6. // Handle Lack Of Response
  7. if( ! $response || empty( $response ) ) { return false; }
  8. $number_of_products_obj = Bigcommerce_parser::XmlToObject( $response, 'number_of_products' );
  9. $number_of_products = $number_of_products_obj->count->__toString();
  10.  
  11. $number_of_pages = intval($number_of_products/50)+ 1;
  12.  
  13. $all_products = array();
  14.  
  15. for ($ndx=1; $ndx<=$number_of_pages; $ndx++) {
  16. $products = array();
  17.  
  18. // Query Bigcommerce API
  19. $query_vars = array( 'page' => $ndx);
  20. $response = self::communicate( 'products?' . http_build_query($query_vars), $cache );
  21.  
  22. // Handle Lack Of Response
  23. if( ! $response || empty( $response ) ) { return false; }
  24. $products = Bigcommerce_parser::XmlToObject( $response, 'product' );
  25.  
  26. foreach( $products as $product ) {
  27. array_push($all_products,$product);
  28. }
  29.  
  30. }
  31.  
  32. return $all_products;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement