Page 1 of 1

Categories in search result (image problem)

Posted: Wed Jun 13, 2018 8:14 am
by BOUSCAT123
Hello, i have made something that display categories as result in search.tpl but i do not get the image of the category i don't understand why. It's a lot frustrating because everything works but the image category.


Here is the code into controler of product/search.php

Code: Select all

[...}
$product_total = $this->model_catalog_product->getTotalProducts($filter_data);
				$this->load->model('catalog/categories_search');
				$categories_result = $this->model_catalog_categories_search->searchCategories(str_replace('-', '_', $filter_data['filter_name']));
				$data['categories'] = array();
				foreach ($categories_result as $category) {
				
					if ($category['image']) {
						$image = $this->model_tool_image->resize($category['image'], 512, 200);
					} else {
						$image = $this->model_tool_image->resize('placeholder.png', 512, 200);
					}
				
					$data['categories'][] = array(
							'category_id'  	=> $category['category_id'],
							'image'       		=> $image,
							'name'        		=> $category['name'],
					);
				}
Model of this categories search:

Code: Select all

<?php class ModelCatalogCategoriesSearch extends Model {

    public function searchCategories($term) {


        $categories = [];
        if (!empty($term)) {
            $categories_sql = "SELECT * FROM " . DB_PREFIX . "category WHERE name LIKE '%" . $this->db->escape($term) . "%' ORDER BY name ASC;";

            $categories_query = $this->db->query($categories_sql);

            foreach ($categories_query->rows as $category) {
                $categories[$category['category_id']] = $category;
            }
        }

        return $categories;
    }

}
And the product/search.tpl:

Code: Select all

				<?php if ($categories) { ?>

				        <?php foreach ($categories as $category) { ?>
				        <a href="index.php?route=product/category&path=<?php echo $category['category_id']; ?>">
				          <img src="<?php echo $category['image']; ?>"/>
					<?php echo $category['name']; ?></a>
				        <?php } ?>

				<?php } ?>

Re: Categories in search result (image problem)

Posted: Wed Jun 13, 2018 9:17 am
by IP_CAM
A rare opportunity, as it looks, for beeing such an Oldie here ... :D (since 09 Dec 2012)
But to solve this problem, you better ask for pro assistance in the commercial
section of this forum, many Dev's don't come here anymore, and so don't see
your Posting. And with 100'000+ clients since 1999, I guess you should be able to
afford it too :D
Good Luck, nothing personal, just making a joke !
Ernie
https://www.wineandco.com/ch--teau-l-ar ... ur-fr.html

Re: Categories in search result (image problem)

Posted: Wed Jun 13, 2018 3:34 pm
by BOUSCAT123
Hello, i have made a modification of a module that display manufacturers in search result to display category. The developper didn't answer for a previous support ask since 3 days then i think as he has developped 2 modules and was not connected since 2016 he will not answer.
This is why i ask for some help here. I don't think somebody will help me, but if it could be possible i would be really happy to display manufacturers with images in search results.

Nobody has an idea to solve this problem?