Esempio n. 1
0
 public function _products($request)
 {
     $productService = \Akzo\Product\Service::getInstance();
     $searchToken = $request->getParam('searchStr');
     $filter = $request->getParam('filter');
     if (isset($filter['products'])) {
         $products = $productService->getProducts($searchToken);
     }
     if (isset($filter['subbrands'])) {
         $subbrands = $productService->getProductSubBrands($searchToken);
     }
     if (isset($filter['groups'])) {
         $groups = $productService->getProductGroups($searchToken);
     }
     if (isset($filter['clusters'])) {
         $clusters = $productService->getProductCLusters($searchToken);
     }
     $productlist = array();
     if (!empty($products)) {
         foreach ($products as $idx => $res) {
             $productlist[] = array('name' => $res->name . " (" . $res->code . ")", 'pid' => $res->pid);
             // $GLOBALS['logger']->info('PID: '.PHP_EOL.print_r($res->pid,1));
         }
     }
     $subbrandlist = array();
     if (!empty($subbrands)) {
         foreach ($subbrands as $idx => $res) {
             $subbrandlist[] = array('name' => $res->name . " (" . $res->code . ")", 'pid' => $res->pid);
         }
     }
     $grouplist = array();
     if (!empty($groups)) {
         foreach ($groups as $idx => $res) {
             $grouplist[] = array('name' => $res->name . " (" . $res->code . ")", 'pid' => $res->pid);
         }
     }
     $clusterlist = array();
     if (!empty($clusters)) {
         foreach ($clusters as $idx => $res) {
             $clusterlist[] = array('name' => $res->name . " (" . $res->code . ")", 'pid' => $res->pid);
         }
     }
     // $GLOBALS['logger']->info('request is there'.PHP_EOL.print_r($productlist,1));
     $result = json_encode(array(array('name' => 'Default', 'children' => array(array('name' => "All Products", 'pid' => "All")), 'disabled' => true), array('name' => 'Clusters', 'children' => $clusterlist, 'disabled' => true), array('name' => 'Sub Brands', 'children' => $subbrandlist, 'disabled' => true), array('name' => 'Groups', 'children' => $grouplist, 'disabled' => true), array('name' => 'Products', 'children' => $productlist, 'disabled' => true)));
     // $GLOBALS['logger']->info('request is there'.PHP_EOL.print_r($result,1));
     // $jsondata = '[{'name':'cluster','children':[{'name':'Chillium','code':'ISOPOP'},{'name':'Netplode','code':'SARASONIC'},{'name':'Progenex','code':'ZEDALIS'},{'name':'Undertap','code':'MAGNEATO'},{'name':'Amtap','code':'EXPOSA'},{'name':'Kongene','code':'AMRIL'},{'name':'Uxmox','code':'LYRIA'},{'name':'Pheast','code':'COMVEX'},{'name':'Matrixity','code':'DATAGENE'},{'name':'Pearlesex','code':'NORSUL'}]},{'name':'group','children':[{'name':'Senmao','code':'VISALIA'},{'name':'Ecosys','code':'GLOBOIL'},{'name':'Zenolux','code':'LEXICONDO'},{'name':'Geekosis','code':'GOKO'},{'name':'Macronaut','code':'FANFARE'},{'name':'Eschoir','code':'KROG'},{'name':'Zyple','code':'COMFIRM'},{'name':'Multiflex','code':'SOFTMICRO'},{'name':'Comveyor','code':'ISOLOGIX'},{'name':'Voipa','code':'REPETWIRE'}]},{'name':'subbrand','children':[{'name':'Orbixtar','code':'FITCORE'},{'name':'Rotodyne','code':'LUNCHPAD'},{'name':'Callflex','code':'MANGLO'},{'name':'Microluxe','code':'SPEEDBOLT'},{'name':'Jetsilk','code':'VALREDA'}]},{'name':'product','children':[{'code':'CODACT','name':'Wendy Lopez','shortcode':'Thredz','packsize':6.107,'dpl':7720.43,'mrp':3443.05},{'code':'ZENTRY','name':'Harvey Lindsay','shortcode':'Cytrak','packsize':9.549,'dpl':9485.6,'mrp':3974.32},{'code':'CORMORAN','name':'Patrica Simmons','shortcode':'Locazone','packsize':6.885,'dpl':5143.81,'mrp':2124.88},{'code':'UNQ','name':'Dena Poole','shortcode':'Oulu','packsize':6.116,'dpl':4326.3,'mrp':2800.09},{'code':'QUIZKA','name':'Walker Owens','shortcode':'Caxt','packsize':5.716,'dpl':4293.69,'mrp':975},{'code':'ZBOO','name':'Burton Hatfield','shortcode':'Zinca','packsize':1.481,'dpl':1772.67,'mrp':3421.87}]}]';
     $json = json_decode($result, true);
     $this->_response = new HttpResponse('json');
     $this->_response->setBody($json);
 }
Esempio n. 2
0
 /** @param $products \Akzo\Scheme\Data\Common\Product[] */
 public function transformProductsToIds($products, $projectSku, $packTypes = array(\Akzo\Scheme\Data\Common\Product\PackType::RETAIL, \Akzo\Scheme\Data\Common\Product\PackType::BULK))
 {
     // Initialize the include / exclude Product Ids
     $includedProductIds = $excludedProductIds = array();
     // Iterate through the products and create the included / excluded array
     foreach ($products as $idx => $product) {
         if (isset($product->excluded) && $product->excluded == true) {
             $excludedProductIds = array_merge($excludedProductIds, \Akzo\Product\Service::getInstance()->getProductIdsByPid($product->pid, $packTypes, $projectSku));
         } else {
             $includedProductIds = array_merge($includedProductIds, \Akzo\Product\Service::getInstance()->getProductIdsByPid($product->pid, $packTypes, $projectSku));
         }
     }
     // Return a differential of the included and excluded products
     return array_diff($includedProductIds, $excludedProductIds);
 }
Esempio n. 3
0
 private function _convertProductsToIds($products, $packs, $projectSku)
 {
     $productsKey = '_PRODUCT_' . \Akzo\Scheme\Utils::condenseProductsPid($products);
     // Check if the converted ids are in the cache already
     if ($this->cache->exists($productsKey)) {
         //$GLOBALS['logger']->info('Got productsKey in cache - '.$productsKey);
         return $this->cache->get($productsKey);
     }
     //$GLOBALS['logger']->info('Did not get productsKey in cache - '.$productsKey);
     // Translate products list to product ids
     $translatedIds = \Akzo\Product\Service::getInstance()->transformProductsToIds($products, $projectSku, $packs);
     // Set it in cache
     $this->cache->set($productsKey, $translatedIds);
     $GLOBALS['logger']->info('Prod IDS length: ' . sizeof($translatedIds));
     return $translatedIds;
 }
Esempio n. 4
0
 public function _select($request)
 {
     $productService = \Akzo\Product\Service::getInstance();
     $searchToken = $request->getParam("searchStr");
     $filter = $request->getParam("filter");
     $products;
     $groups;
     $subbrands;
     if (isset($filter['products'])) {
         $products = $productService->getProducts($searchToken);
     }
     if (isset($filter['subbrands'])) {
         $subbrands = $productService->getProductSubBrands($searchToken);
     }
     if (isset($filter['groups'])) {
         $groups = $productService->getProductGroups($searchToken);
     }
     $productlist = array();
     foreach ($products as $idx => $res) {
         $productlist[] = array('name' => $res->name, 'code' => $res->name);
     }
     $subbrandlist = array();
     foreach ($subbrands as $idx => $res) {
         $subbrandlist[] = array('name' => $res->name, 'code' => $res->name);
     }
     $grouplist = array();
     foreach ($groups as $idx => $res) {
         $grouplist[] = array('name' => $res->name, 'code' => $res->name);
     }
     // $GLOBALS['logger']->info("request is there".PHP_EOL.print_r($productlist,1));
     $result = json_encode(array(array("name" => "Products", "children" => $productlist, "disabled" => true), array("name" => "Sub Brands", "children" => $subbrandlist, "disabled" => true), array("name" => "Groups", "children" => $grouplist, "disabled" => true)));
     // $GLOBALS['logger']->info("request is there".PHP_EOL.print_r($result,1));
     // $jsondata = '[{"name":"cluster","children":[{"name":"Chillium","code":"ISOPOP"},{"name":"Netplode","code":"SARASONIC"},{"name":"Progenex","code":"ZEDALIS"},{"name":"Undertap","code":"MAGNEATO"},{"name":"Amtap","code":"EXPOSA"},{"name":"Kongene","code":"AMRIL"},{"name":"Uxmox","code":"LYRIA"},{"name":"Pheast","code":"COMVEX"},{"name":"Matrixity","code":"DATAGENE"},{"name":"Pearlesex","code":"NORSUL"}]},{"name":"group","children":[{"name":"Senmao","code":"VISALIA"},{"name":"Ecosys","code":"GLOBOIL"},{"name":"Zenolux","code":"LEXICONDO"},{"name":"Geekosis","code":"GOKO"},{"name":"Macronaut","code":"FANFARE"},{"name":"Eschoir","code":"KROG"},{"name":"Zyple","code":"COMFIRM"},{"name":"Multiflex","code":"SOFTMICRO"},{"name":"Comveyor","code":"ISOLOGIX"},{"name":"Voipa","code":"REPETWIRE"}]},{"name":"subbrand","children":[{"name":"Orbixtar","code":"FITCORE"},{"name":"Rotodyne","code":"LUNCHPAD"},{"name":"Callflex","code":"MANGLO"},{"name":"Microluxe","code":"SPEEDBOLT"},{"name":"Jetsilk","code":"VALREDA"}]},{"name":"product","children":[{"code":"CODACT","name":"Wendy Lopez","shortcode":"Thredz","packsize":6.107,"dpl":7720.43,"mrp":3443.05},{"code":"ZENTRY","name":"Harvey Lindsay","shortcode":"Cytrak","packsize":9.549,"dpl":9485.6,"mrp":3974.32},{"code":"CORMORAN","name":"Patrica Simmons","shortcode":"Locazone","packsize":6.885,"dpl":5143.81,"mrp":2124.88},{"code":"UNQ","name":"Dena Poole","shortcode":"Oulu","packsize":6.116,"dpl":4326.3,"mrp":2800.09},{"code":"QUIZKA","name":"Walker Owens","shortcode":"Caxt","packsize":5.716,"dpl":4293.69,"mrp":975},{"code":"ZBOO","name":"Burton Hatfield","shortcode":"Zinca","packsize":1.481,"dpl":1772.67,"mrp":3421.87}]}]';
     $json = json_decode($result, true);
     $this->_response = new HttpResponse('json');
     $this->_response->setBody($json);
 }