Exemplo n.º 1
0
 /**
  * generateJSMap
  *
  */
 function generateJSMap($tags_names_arr)
 {
     $output = '';
     if (count($tags_names_arr) > 0) {
         $getproductsPath = $this->modx->getOption('core_path') . "components/getproducts/model/getproducts.class.php";
         if (file_exists($getproductsPath)) {
             require_once $getproductsPath;
             $snippetProperties = $this->getSnippetProperties();
             $snippetProperties['limit'] = 0;
             $getProducts = new getProducts($this->modx, $snippetProperties);
             if (!empty($this->config['className']) && $this->config['className'] != 'modResource') {
                 array_push($tags_names_arr, 'id');
                 $getProducts->table_fields = $tags_names_arr;
             } else {
                 $getProducts->table_fields = array('id');
             }
             $getProducts->searchProducts();
             $total = $getProducts->getTotal();
             if ($total > 0) {
                 if (empty($this->config['className']) || $this->config['className'] == 'modResource') {
                     $getProducts->config['includeTVs'] = 1;
                     $getProducts->config['includeTVList'] = implode(',', $tags_names_arr);
                     $getProducts->config['includeTVList_arr'] = $tags_names_arr;
                     $getProducts->appendTVs('');
                 }
                 foreach ($getProducts->ids_arr as $r_id) {
                     if (isset($getProducts->products[$r_id])) {
                         $product = $getProducts->products[$r_id];
                         ksort($product);
                         $output .= $this->php2js(array_merge(array("id" => $r_id), $product)) . ",\n";
                     }
                 }
             }
         } else {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'tagManager: Unable to find a snippet getProducts.');
         }
     }
     if (strlen($output) > 0) {
         $output = "\n<script type=\"text/javascript\">\n            var flt_data = {\"products\": [\n" . (strlen($output) > 2 ? substr($output, 0, -2) : "") . "\n]};\n\n            </script>\n";
     }
     return $output;
 }
Exemplo n.º 2
0
<?php

require_once 'include.php';
$requestURL = 'http://www.sainsburys.co.uk/webapp/wcs/stores/servlet/CategoryDisplay?listView=true&orderBy=FAVOURITES_FIRST&parent_Category_rn=12518&top_category=12315&&langId=44&beginIndex=0&pageSize=20&catalogId=10137&searchTerm=&categoryId=185749&listId=&storeId=10151&promotionId=#langId=44&storeId=10151&catalogId=10137&categoryId=185749&parent_category_rn=12518&top_category=12518&pageSize=20&orderBy=FAVOURITES_FIRST&searchTerm=&beginIndex=0&hideFilters=true';
$product = new getProducts($requestURL);
$productAry = $product->getProducts();
echo toJSON::getJSON($productAry);