PanosStack Posted March 21, 2018 Posted March 21, 2018 cname:"something" crewrite:"something else" id_product:"something else" pname:"something else" position:"100" prewrite:"something -else" product_link:"https://something-else" pthumb:"https://mydomain/something else.jpg" Μπήκα στο αρχείο /httpdocs/modules/blocksearch_mod/views/js/blocksearch.js και πρόσθεσα console.log(data); για να δω τι αποτελέσματα μου στέλνει στην jquery... Μου φερε αυτά που βλέπετε αλλά δεν μου φέρνει την τιμή... Υπάρχει κάποια συνάρτηση στην php που πρέπει να παραμετροποιήσω για να τραβάω και την τιμή? Share this post Link to post Share on other sites More sharing options...
nextpointer Posted April 19, 2018 Posted April 19, 2018 Καλησπέρα. για ποία εκδοσή prestashop μιλάμε ? Share this post Link to post Share on other sites More sharing options...
PanosStack Posted April 27, 2018 Posted April 27, 2018 Καλησπέρα το πρόβλημα λύθηκε. Η έκδοση που χρησιμοποιω είναι η 1.6.1.17. Έφτιαξα το εξής directory στο φάκελο modules: stoverride/override/controllers /front. Εκεί δημιούργησα εναν καινούργιο controller με το όνομα SearchController.php. Ο κώδικας είναι ο παρακάτω και με σχόλιο επισημαίνω την γραμμή με την οποία τραβάω την τιμή κάθε προιόντος και την στέλνω στην jQuery. class SearchController extends SearchControllerCore { public function initContent() { $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q'))); if ($this->ajax_search) { $image = new Image(); $searchResults = Search::find((int)(Tools::getValue('id_lang')), $query, 1, 10, 'position', 'desc', true); foreach ($searchResults as &$product) { // ADD $product['product_price'] to send it on jquery $product['product_price'] = number_format(Product::getPriceStatic($product['id_product']),2); $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']); $imageID = $image->getCover($product['id_product']); if(isset($imageID['id_image'])) $product['pthumb'] = $this->context->link->getImageLink($product['prewrite'], (int)$product['id_product'].'-'.$imageID['id_image'], 'small_default'); else $product['pthumb'] = _THEME_PROD_DIR_.$this->context->language->iso_code."-default-small_default.jpg"; } die(Tools::jsonEncode($searchResults)); } parent::initContent(); } } Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now