Jump to content

dasunp

Members
  • Posts

    3
  • Joined

  • Last visited

Profile Information

  • First Name
    Dasun
  • Last Name
    Polwatta

dasunp's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Oh got it. I'm using v1.7.1.0 Sorry I've forgotten to mention that. So if a targeted site happens to be made on that same version, in almost all cases the db structure would be the same. But it would anyway be better to have some validations there to be on the safe side I guess. Thank you so much for clearing this out for me. Best Regards Dasun
  2. Do all the Prestashop based sites share the same database table structure? For example, if I need to get the cart quantity, would it be ok to use the following command in my module, or would the 'cart quantity' key change from site to site? $cartQty = (int)Configuration::get('cart_quantity');
  3. Hello I'm coding a test module targeted at retail stores. In my module, when a user queries through the search bar I need to echo the following Search term Search results (first 100 products semicolon separated) I've already coded the methods for those and set them to be fired by an actionSearch hook but the results are not displayed. I have found that action hooks cannot deal with php echos. But I still couldn't find a proper way to do it. I'll post all the relevant code here. Any help is much much appreciated. P. S. : I can't deal with templates since the module will be targeted towards various customer sites. public function hookactionSearch($params) { $this->displaySearchDetails(); } // Module install method public function install() { if (Shop::isFeatureActive()) Shop::setContext(Shop::CONTEXT_ALL); if (!parent::install() || !$this->registerHook('actionSearch') ) return false; return true; } // Display search details private function displaySearchDetails() { $searchTerm = $this->getSearchTerm(); if (empty($searchTerm)) { return; } echo '<b>Search Details : </b><br>'; $this->displaySearchTerm($searchTerm); $this->displaySearchResultsProdIds($searchTerm); } // Get the search term private function getSearchTerm() { $searchTerm = Tools::getValue(self::SEARCH_REQ_PARAM_KEY); $trimmedSearchTerm = trim($searchTerm); return $trimmedSearchTerm; } // Display search term private function displaySearchTerm($searchTerm) { echo 'Search Term : ' . $searchTerm . '<br>'; } // Display search results first 100 products semicolon separated product ids private function displaySearchResultsProdIds($searchTerm) { $searchLimitOffset = 1; //Set search results limit to the catalog size $searchLimit = count(Product::getProducts($this->context->language->id, 1, PHP_INT_MAX, 'name', 'ASC')); $resultsArr = Search::find($this->context->language->id, $searchTerm, $searchLimitOffset, $searchLimit); $searchResultsArr = $resultsArr[self::SEARCH_RESULTS_ARR_KEY]; $prodIdArr = array(); $resultsCount = count($searchResultsArr); for ($i=0; ($i<$resultsCount && $i<100); $i++) { $singleSearchResultArr = $searchResultsArr[$i]; if (isset($singleSearchResultArr[self::PROD_ID_PARAM_KEY])) { array_push($prodIdArr, $singleSearchResultArr[self::PROD_ID_PARAM_KEY]); } } $semiColonSeparatedProdIds = implode(self::SEMICOLON_STR, $prodIdArr); echo 'Search Results Product Ids : ' . $semiColonSeparatedProdIds . '<br>'; }
×
×
  • Create New...