Forums / Templates, Stylesheets, Page Layout / Exclude a category from new products migration

Exclude a category from new products migration

Views: 1,934

Results 1 to 17 of 17
11 Feb 2012, 8:28 AM
#1
shags38 avatar

shags38

Totally Zenned

Join Date:
Jan 2011
Location:
Adelaide, Australia
Posts:
1,684
Plugin Contributions:
0

Exclude a category from new products migration

Hi,

I wish to exclude a category from new products migration so that new entries in that category do not show up in "new products".

Can this be done - any help appreciated.

cheers,
Mike

11 Feb 2012, 8:50 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Exclude a category from new products migration

You need to edit the SELECT statements on any thing you do not want a specific master_categories_id to show up on ...

Add to the WHERE statement:
and p.master_categories_id != xx

where XX is the categories_id you do not want added ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

11 Feb 2012, 11:54 PM
#3
shags38 avatar

shags38

Totally Zenned

Join Date:
Jan 2011
Location:
Adelaide, Australia
Posts:
1,684
Plugin Contributions:
0

Re: Exclude a category from new products migration

Ajeh:

You need to edit the SELECT statements on any thing you do not want a specific master_categories_id to show up on ...

Add to the WHERE statement:
and p.master_categories_id != xx

where XX is the categories_id you do not want added ...

Many Thanks Linda - where will I find this "SELECT" data - is it in Categories.php or elsewhere?

cheers,
Mike

12 Feb 2012, 12:09 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Exclude a category from new products migration

If you want to control the New Products then it would be in the module or sidebox or listing for New Products ...

/includes/modules/pages/products_new/header_php.php
/includes/modules/sideboxes/whats_new.php
/includes/modules/new_products.php

be sure to use your templates and overrides for any changes that you make ...

NOTE: the header file does not have a templates and overrides for it ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 Feb 2012, 4:23 AM
#5
golowenow avatar

golowenow

New Zenner

Join Date:
Jul 2006
Location:
Washington State
Posts:
78
Plugin Contributions:
0

Re: Exclude a category from new products migration

Have been trying this code in various files in Zencart 1.5 and it is not doing anything.

In header_php.php in products_new folder have noticed code now reads:

WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $display_limit . $order_by;

No $order_by in earlier versions. This code is in the other files also.

Tried: #1

WHERE p.products_status = 1
AND p.master_categories_id != 7
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $display_limit . $order_by;

Does not work.
Tried: #2

WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $display_limit . $order_by;
AND p.master_categories_id != 7

Still nothing. moved the semicolon to the bottom. Just caused a blank page.

Is the newer coding for version 1.5 causing this? This SHOULD exclude category 7 from the New Products page yes?

29 Feb 2012, 2:03 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Exclude a category from new products migration

This is the one that you want to use:

WHERE p.products_status = 1
AND p.master_categories_id != 7
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $display_limit . $order_by;

and any Product with master_categories_id 7 will not be included ...

Check your Product(s) if still showing and make sure that the master_categories_id is 7 ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

24 Apr 2012, 11:47 PM
#7
shags38 avatar

shags38

Totally Zenned

Join Date:
Jan 2011
Location:
Adelaide, Australia
Posts:
1,684
Plugin Contributions:
0

Re: Exclude a category from new products migration

Ajeh:

If you want to control the New Products then it would be in the module or sidebox or listing for New Products ...

/includes/modules/pages/products_new/header_php.php
/includes/modules/sideboxes/whats_new.php
/includes/modules/new_products.php

be sure to use your templates and overrides for any changes that you make ...

NOTE: the header file does not have a templates and overrides for it ...

Hi Linda,

I must be a dummy - I still cannot stop a product category showing up in new products (v1,3,9). As your response did not indicate what code to change or add I used the line "AND p.master_categories_id != 7" from the next post of yours, however I noted that the discussion was for v1.5. I added this "line" to existing code in each of the 3 files you mentioned and still no joy.

It is very frustrating because I have a product category that is purely ARTICLES which I add in blocks of 20 or more every so often for SEO purposes (using a product category because EZ-pages was an issue) - so suffice to say sometimes the whole new products display box (center) is full of articles (which are not really meant for customers anyway - take a look).

So looking for an "exclusion code" if there is such a thing.

cheers,
Mike

25 Apr 2012, 1:28 PM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Exclude a category from new products migration

Could you go into phpMyAdmin and search for the products_id that you do not want to see and see what their master_categories_id are?

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Apr 2012, 12:42 AM
#9
shags38 avatar

shags38

Totally Zenned

Join Date:
Jan 2011
Location:
Adelaide, Australia
Posts:
1,684
Plugin Contributions:
0

Re: Exclude a category from new products migration

Ajeh:

Could you go into phpMyAdmin and search for the products_id that you do not want to see and see what their master_categories_id are?

Linda - not sure where to find "phpMyAdmin" ? Checking other sources, category listing in admin, the category I.D. to be excluded is 23. In the line "AND p.master_categories_id != 7" mentioned above I changed 7 to read 23 with no result. Here are the codes as they now exist - maybe I have the "line" of code mentioned above in the wrong order?

from /includes/modules/pages/products_new/header_php.php

// $display_limit = zen_get_products_new_timelimit();
$display_limit = zen_get_new_date_range();

$products_new_query_raw = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price,
p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model,
p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m
ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.master_categories_id != 23
AND p.products_id = pd.products_id
AND pd.language_id = :languageID " . $display_limit . $order_by;

from /includes/modules/new_products.php

// initialize vars
$categories_products_id_list = '';
$list_of_products = '';
$new_products_query = '';

$display_limit = zen_get_new_date_range();

if ( (($manufacturers_id > 0 && $_GET['filter_id'] == 0) || $_GET['music_genre_id'] > 0 || $_GET['record_company_id'] > 0) || (!isset($new_products_category_id) || $new_products_category_id == '0') ) {
$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 " . $display_limit;
} else {
// get all products and cPaths in this subcat tree
$productsInCategory = zen_get_categories_products_list( (($manufacturers_id > 0 && $_GET['filter_id'] > 0) ? zen_get_generated_category_path_rev($_GET['filter_id']) : $cPath), false, true, 0, $display_limit);

if (is_array($productsInCategory) && sizeof($productsInCategory) > 0) {
// build products-list string to insert into SQL query
foreach($productsInCategory as $key => $value) {
$list_of_products .= $key . ', ';
}
$list_of_products = substr($list_of_products, 0, -2); // remove trailing comma

$new_products_query = "select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
                              p.products_date_added, p.products_price, p.products_type, p.master_categories_id
                       from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                       where p.products_id = pd.products_id
                       and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
                       and p.products_status = 1
					   and p.master_categories_id != 23
                       and p.products_id in (" . $list_of_products . ")";

}
}

from /includes/modules/sideboxes/whats_new.php

// display limits
// $display_limit = zen_get_products_new_timelimit();
$display_limit = zen_get_new_date_range();
$random_whats_new_sidebox_product_query = "select p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name,
p.master_categories_id
from (" . TABLE_PRODUCTS . " p
left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id )
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.master_categories_id != 23
and p.products_status = 1 " . $display_limit;

I have also attached a screen capture of the index page showing my problem - not sure if it will show up - if not then just click on my site link below - obviously new products images rotate so you may need to leave home page then return to see it - just a bunch of Articles using the same image - looks terrible to say the least. (I wouldn't shop here, would you?)

The reason I use a Product Category to insert Articles is that when using EZ Pages I cannot find a way to add meta descriptions, keywords etc for SEO benefit (the only reason I bother with articles in the first place)

[Attachment no longer available]

So Linda, I very much look forward to your help here.

cheers,
Mike

26 Apr 2012, 2:48 AM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Exclude a category from new products migration

phpMyAdmin is located in your domain hosting Control Panel such as cPanel ...

If you are not sure how to get to it, contact your hosting provider and ask them ...

Also in the file:
/includes/modules/new_products.php

there are two places to add this ... you missed one of the $new_products_query you only added it to one part ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

26 Apr 2012, 6:42 AM
#11
shags38 avatar

shags38

Totally Zenned

Join Date:
Jan 2011
Location:
Adelaide, Australia
Posts:
1,684
Plugin Contributions:
0

Re: Exclude a category from new products migration

Ajeh:

phpMyAdmin is located in your domain hosting Control Panel such as cPanel ...

If you are not sure how to get to it, contact your hosting provider and ask them ...

Also in the file:
/includes/modules/new_products.php

there are two places to add this ... you missed one of the $new_products_query you only added it to one part ...

FANTASTIC !! Many thanks Linda - adding that line in the second place worked a treat. You don't know how much it means to me to finally get this issue solved.

Great work - if I can help you one day just holler :D

cheers,
Mike

p.s. this particular site is hosted in Australia - the host does not have cPanel facilities - as much as we Australians have a good reputation as sports people and having handsome men we unfortunately are still looking for the door to exit the dark ages when it comes to quality hosting with up to date technology :blink: hence my not recognizing phpMyAdmin

29 May 2012, 12:35 PM
#12
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Exclude a category from new products migration

I have a similar setup but trying to take it a step further and exclude all sub-categories as well. Here is the code I'm using:

$display_limit = zen_get_new_date_range();

$products_new_query_raw = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price,
p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model,
p.products_quantity, p.products_weight, p.product_is_call,
p.product_is_always_free_shipping, p.products_qty_box_status,
p.master_categories_id
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_MANUFACTURERS . " m
ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
WHERE p.products_status = 1
AND p.products_id = pd.products_id
AND p.master_categories_id != 349
AND p.master_categories_id != 245
AND p.master_categories_id != 377
AND p.master_categories_id != 380
AND p.master_categories_id != 350
AND pd.language_id = :languageID " . $display_limit . $order_by;

$products_new_query_raw = $db->bindVars($products_new_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
$products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

380 is a sub category of 377. I'm planning to add quite a few more sub-categories to 377 as well but don't want to have to keep adding a new line. Is there a bit of code I could add to " AND p.master_categories_id != 380 " so that all the sub-categories are also excluded?

29 May 2012, 1:21 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Exclude a category from new products migration

You could use on the immediate master_categories_id of these Products:

and p.master_categories_id NOT IN (10, 12, 15)

Where 10, 12, 15 are the specific Categories that are the master_categories_id ...

And, you could use a define statement or add something to the database us:

and master_categories_id NOT IN (" . MY_BLOCKED_MASTERS . ")

Where you set the values of:

define('MY_BLOCKED_MASTERS', '10,12,15');

In a file such as:
/includes/extra_configures/my_blocked_masters.php

containing the code:

<?php
// block master_categories_id from new_products
define('MY_BLOCKED_MASTERS', '10,12,15');

or make a setting in the configuration table to show in the Configuration ... Index Listing ... where you can update this as needed ...

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) VALUES ('New Products Module Block master_categories_id', 'MY_BLOCKED_MASTERS', '10,12,15', 'What master_categories_id should not show in new_products centerbox', '24', '600', now());

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 May 2012, 1:33 PM
#14
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Exclude a category from new products migration

Perfect! I just used this:

  $display_limit = zen_get_new_date_range();

  $products_new_query_raw = "SELECT p.products_id, p.products_type, pd.products_name, p.products_image, p.products_price,
                                    p.products_tax_class_id, p.products_date_added, m.manufacturers_name, p.products_model,
                                    p.products_quantity, p.products_weight, p.product_is_call,
                                    p.product_is_always_free_shipping, p.products_qty_box_status,
                                    p.master_categories_id
                             FROM " . TABLE_PRODUCTS . " p
                             LEFT JOIN " . TABLE_MANUFACTURERS . " m
                             ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
                             WHERE p.products_status = 1
                             AND p.products_id = pd.products_id
			     AND p.master_categories_id NOT IN (377, 245, 349, 350)
                             AND pd.language_id = :languageID " . $display_limit . $order_by;

  $products_new_query_raw = $db->bindVars($products_new_query_raw, ':languageID', $_SESSION['languages_id'], 'integer');
  $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);
29 May 2012, 1:59 PM
#15
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Exclude a category from new products migration

Make sure that you are using the true master_categories_id ...

The master_categories_id is the categories_id of the Category that holds the Product, not the parent of that Category ...

So if categories_id 380 is a subcategory of categories_id 377, and the Product is actually in categories_id 380 you would use 380 not 377 ...

You can edit the Product to see what its master_categories_id is ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

29 May 2012, 2:09 PM
#16
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Exclude a category from new products migration

Hi Ajeh,

Those are definitely the Master categories. I have products in my master categories as I keep the sub categories in an "enabling category" elsewhere. This is how I've managed to show all products and sub category products when you click on the master categories. Confused? It works well though :)

29 May 2012, 2:10 PM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Exclude a category from new products migration

Thanks for the update that this is all working happily for you ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!