Results 1 to 5 of 5

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    82
    Plugin Contributions
    0

    Default Reviews on category page

    Hello!
    I would be very grateful if somebody could help me with the sql query to display reviews on categories pages. Right now I am using the dgReviews module which is awesome but I would like to change it a bit and display not just any reviews but only reviews from products in that category. I am not a php coder but as far as I understand I need to use the products_to_categories table, but how I have no idea.

    Here is the query on how to display latest ten reviews, could somebody point me what changes needed to do what I am asking above?

    Code:
     $review_status = " and r.status = '1'";
      /* This is where you change the parameter value to output 1000 charaters or equivelent */
      $reviews_query_raw = "select r.reviews_id, r.customers_name, r.reviews_rating, p.products_id, p.products_image, pd.products_name,
                        substring(reviews_text, 1, 70) as reviews_text
                        from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, "
                               . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                        where p.products_status = '1'
    					where p.products_status = '1'
                        and p.products_id = r.products_id
                        and r.reviews_id = rd.reviews_id
                        and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'
                        and p.products_id = pd.products_id
                        and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                        $review_status . "
                        order by r.reviews_id desc limit 10";
    Thank you very much for your help!
    Dan

  2. #2
    Join Date
    Apr 2008
    Posts
    82
    Plugin Contributions
    0

    Default Re: Reviews on category page

    Well,
    I found a way to display reviews from a specific category only, it is just, as I mentioned before, am not a coder so it would be good if somebody more experienced than me could take a look at it to make sure it does not have any "holes".
    Thanks

    Code:
      $reviews_query_raw = "select r.reviews_id, r.customers_name, r.reviews_rating, p.products_id, p.products_image, c.categories_id, pd.products_name,
                        substring(reviews_text, 1, 70) as reviews_text
                        from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, "
                               . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " c, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                        where p.products_status = '1'
                        and p.products_id = r.products_id
    					and p.products_id = c.products_id
    					and c.categories_id = " . $current_category_id . "
                        and r.reviews_id = rd.reviews_id
                        and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'
                        and p.products_id = pd.products_id
                        and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                        $review_status . "
                        order by r.reviews_id desc";

  3. #3
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Reviews on category page

    Quote Originally Posted by Dan123 View Post
    Well,
    I found a way to display reviews from a specific category only, it is just, as I mentioned before, am not a coder so it would be good if somebody more experienced than me could take a look at it to make sure it does not have any "holes".
    Thanks

    Code:
      $reviews_query_raw = "select r.reviews_id, r.customers_name, r.reviews_rating, p.products_id, p.products_image, c.categories_id, pd.products_name,
                        substring(reviews_text, 1, 70) as reviews_text
                        from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd, "
                               . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " c, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                        where p.products_status = '1'
                        and p.products_id = r.products_id
    					and p.products_id = c.products_id
    					and c.categories_id = " . $current_category_id . "
                        and r.reviews_id = rd.reviews_id
                        and rd.languages_id = '" . (int)$_SESSION['languages_id'] . "'
                        and p.products_id = pd.products_id
                        and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'" .
                        $review_status . "
                        order by r.reviews_id desc";

    rather than trying to join the products to categories table you would probably be better (safer) selecting:
    p.products_master_categories_id
    or is it
    p.master_categories_id
    as this will already be part of the products table.

    cant rememebr off the top of my head,
    and then do
    and p.products_master_categories_id = " . $current_category_id
    for the WHERE clause...
    Phil Rogers
    A problem shared is a problem solved.

  4. #4
    Join Date
    Apr 2008
    Posts
    82
    Plugin Contributions
    0

    Default Re: Reviews on category page

    Yeap,
    you are totally right! I was probably too lazy to check that the product table has the master category id as well.
    Thank you very much for your help, Phil!

  5. #5
    Join Date
    Aug 2009
    Location
    Bedford, England
    Posts
    966
    Plugin Contributions
    0

    Default Re: Reviews on category page

    No probs glad to help, hope it does what you need it too.
    Phil Rogers
    A problem shared is a problem solved.

 

 

Similar Threads

  1. Replies: 6
    Last Post: 31 Mar 2014, 03:06 PM
  2. Product page - how to show a link to the reviews page and reviews count?
    By Ronson in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 26 Mar 2009, 11:45 PM
  3. Display reviews per category
    By swamyg1 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 11 Jan 2009, 07:21 PM
  4. Replies: 2
    Last Post: 7 Sep 2008, 03:27 PM
  5. Category or product type specific reviews
    By awhfy99 in forum General Questions
    Replies: 4
    Last Post: 6 Sep 2007, 12:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg