Post by BOUSCAT123 » Wed Jun 13, 2018 8:14 am

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 } ?>

Newbie

Posts

Joined
Sun Dec 09, 2012 11:23 pm

Post by IP_CAM » Wed Jun 13, 2018 9:17 am

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

For Sale: Top URL's, including OpenCart V-Pro installed, like seen here:
http://www.bigmax.ch - http://www.ipcam.li - http://www.opencart.li
For Information + URL's offered, please contact me at: jti@jacob.ch
I am NOT available for Custom Support in existing OC Installations!
My Github Repositories: https://github.com/IP-CAM
Image


User avatar
Guru Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by BOUSCAT123 » Wed Jun 13, 2018 3:34 pm

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?

Newbie

Posts

Joined
Sun Dec 09, 2012 11:23 pm
Who is online

Users browsing this forum: No registered users and 7 guests