Advertisement
Guest User

Api.php

a guest
Jun 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. public static function addOffersMobile(&$catalog, $lang)
  2.     {
  3.         $offersModel = new Lmc_Core_Model_Offers_Model();
  4.  
  5.         foreach($catalog as $n => $val) {
  6.             $catalog[$n]['offers'] = $offersModel->getOffersForProducts(array(array('ProductId' => $val['ProductId'])), array('Site' => $lang))->toArray();
  7.         }
  8.     }
  9.  
  10.     /**
  11.      * Get all products for a given category id
  12.      *
  13.      * @param string $token the session token
  14.      * @param string $categoryId the category id (as returned by getMobileLensCategories)
  15.      * @param string $lang [optional] the language
  16.      * @return Lmc_Ws_Response
  17.      */
  18.     public function getLensByCategory($token, $categoryId, $lang = null)
  19.     {
  20.         $response = new Lmc_Ws_Response(__METHOD__);
  21.         $catalog = new Lmc_Ws_Catalog();
  22.  
  23.         try {
  24.             $this->_session->load($token);
  25.             $lang = $this->getLangIfInvalid($lang);
  26.             $response->status = true;
  27.             $response->data->categories = $catalog->getLensByCategory($categoryId, $lang);
  28.             self::addOffersMobile($response->data->categories, $lang);
  29.         } catch (Exception $e) {
  30.             $response->error = true;
  31.             $response->status = false;
  32.             $response->errorMessage = $e->getMessage();
  33.             $response->errorCode = $e->getCode();
  34.         }
  35.  
  36.         return $this->addDebugAndReturnResponse($response);
  37.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement