Jump to content

Modifying the Category SQL & displaying results


Recommended Posts

Hi,

 

I'd like to be able to modify or add to the SQL queries executed and get different results based on a number of different inputs. I'd like to keep the view consistent with how the category page looks.

 

Here's the background:

I've set up a shop for a colleague and have created as the first two categories: 'Mens' & 'Womens'. Under each of these two categories will generally be the same sets of sub categories (T-Shirts, Shirts, Trousers etc...). I've added several manufacturer and products.

 

I've had some success but it's not displaying as I would have expected.

 

So far I've overridden the CategoryController.php as I'd like the results of my queries to be displayed in the same way as a standard category listing would. I figured it made sense to modfiy this file and not create a new controller specifically for my queries.

 

I've changed it's behaviour so it doesn't redirect if the id_category value is missing (It still works as normal if it is given a category ID). I've changed its logic so that it performs a different query depending on the GET values passed to it. For example, if given a manufacturer ID and a gender it will pull in results specific to that manufacturer from all categories that fall under 'Women'. The SQL and Prestashop works as expected at this point.

 

The bit I'm currently struggling with is getting the results to show on the page. In order to try and keep existing pagination features I've copied the productListAssign() and getProducts() functions and renamed them as productCustomListAssign() getCustomProducts(). These have been modified slightly to enable them to handle my new input changes.

 

If I get the results the way the original CategoryController does it I'd execute productCustomListAssign() first and then assign $this->cat_products to the $smarty products array. This doesn't work with my changes.

 

If I ignore productCustomListAssign() and just run

$this->cat_products=category::getcreamproducts( .... $my values ....);

 

A print_r($this->cat_products) shows the array with the correct products in. I then pass these to the

self::$smarty->assign(array(
				'products' => ($this->cat_products),
				...

, code and I can see from the Smarty debugging info that the products array is empty.

 

Am I going about this the right way? If not what direction should I be going in? If this approach looks feasible what else can I look at to get the items displayed?

 

If you've read this far you deserve a medal :)

 

Thanks for any help.

 

Kev

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...