Forums / Setting Up Categories, Products, Attributes / setting up attributes file to not show display only in 2.10

setting up attributes file to not show display only in 2.10

Views: 2,684

Results 1 to 7 of 7
25 Feb 2025, 9:06 PM
#1
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
733
Plugin Contributions:
0

setting up attributes file to not show display only in 2.10

php 8.2 zencart 2.10

I have been using the Numinix Google Product Search feeder to add google product categories for many years. I have just upgraded to 2.10, and it seems the code I have added as per their instructions is redundant. The goal is to stop showing display only attributes on the product info page, otherwise it looks a little confusing for the customer.

I have to add this element:-

   and      patrib.attributes_display_only = 0 

I was getting an error regarding the '=' symbol

So I think it needs to be :-

   and      patrib.attributes_display_only == 0 

But now I get an error log as below:

PHP Fatal error: Uncaught Error: Undefined constant "patrib" in 

I think the attributes has been re-worked now, I guess there is a new constant to replace 'patrib'? Or maybe the whole code needs altering, am not sure.

25 Feb 2025, 9:40 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: setting up attributes file to not show display only in 2.10

it seems the code I have added as per their instructions is redundant ...

where are you adding this code?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

25 Feb 2025, 10:23 PM
#3
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
733
Plugin Contributions:
0

Re: setting up attributes file to not show display only in 2.10

swguy:

it seems the code I have added as per their instructions is redundant ...

where are you adding this code?

Sorry I was a bit vague there. Its includes/modules/attributes.php. I have put the snippet below, its mentioned twice. I know its a developer plugin, it might take them a while to update as they are usually busy. I was curious what the new alternative constant is, if there is one. Bear in mind I have adapted these code snippets to the 2.10 standard, it was working for 1.58a and before, I am aware attributes has been massively reworked so it makes sense it no longer works off the bat:-

// Determine number of attributes associated with this product
$sql = "SELECT count(*) as total
        FROM " . TABLE_PRODUCTS_OPTIONS . " popt
        LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " patrib ON (popt.products_options_id = patrib.options_id)
        WHERE patrib.products_id = :products_id
        AND popt.language_id = :language_id
	      and      patrib.attributes_display_only = 0 
        LIMIT 1";
$sql = $db->bindVars($sql, ':products_id', $_GET['products_id'], 'integer');
$sql = $db->bindVars($sql, ':language_id', $_SESSION['languages_id'], 'integer');
$pr_attr = $db->Execute($sql);

if ($pr_attr->fields['total'] < 1) return;
// Only process the rest of this file if attributes are defined for this product


$prod_id = $_GET['products_id'];
$number_of_uploads = 0;
$zv_display_select_option = 0;
$options_name = $options_menu = $options_html_id = $options_inputfield_id = $options_comment = $options_comment_position = $options_attributes_image = array();
$attributeDetailsArrayForJson = array();

$discount_type = zen_get_products_sale_discount_type((int)$_GET['products_id']);
$discount_amount = zen_get_discount_calc((int)$_GET['products_id']);
$products_price_is_priced_by_attributes = zen_get_products_price_is_priced_by_attributes((int)$_GET['products_id']);


if (PRODUCTS_OPTIONS_SORT_ORDER == '0') {
    $options_order_by = " ORDER BY LPAD(popt.products_options_sort_order,11,'0'), popt.products_options_name";
} else {
    $options_order_by = ' order by popt.products_options_name';
}

$sql = "SELECT DISTINCT popt.products_options_id, popt.products_options_name, popt.products_options_sort_order,
            popt.products_options_type, popt.products_options_length, popt.products_options_comment, popt.products_options_comment_position,
            popt.products_options_size,
            popt.products_options_images_per_row,
            popt.products_options_images_style,
            popt.products_options_rows
        FROM " . TABLE_PRODUCTS_OPTIONS . " popt
        LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " patrib ON (patrib.options_id = popt.products_options_id)
        WHERE patrib.products_id= :products_id
        AND popt.language_id = :language_id " 
	      and      patrib.attributes_display_only == 0 .
        $options_order_by;
$sql = $db->bindVars($sql, ':products_id', $_GET['products_id'], 'integer');
$sql = $db->bindVars($sql, ':language_id', $_SESSION['languages_id'], 'integer');
$products_options_names = $db->Execute($sql);
26 Feb 2025, 3:28 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: setting up attributes file to not show display only in 2.10

You can see the issue from the color coding above. This line:

      and      patrib.attributes_display_only == 0 .

needs to be in quotes. And just one equal sign.

      " and      patrib.attributes_display_only = 0 " .

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

26 Feb 2025, 9:38 PM
#5
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
733
Plugin Contributions:
0

Re: setting up attributes file to not show display only in 2.10

swguy:

You can see the issue from the color coding above. This line:

      and      patrib.attributes_display_only == 0 .

needs to be in quotes. And just one equal sign.

      " and      patrib.attributes_display_only = 0 " .

Thanks for that Scott, I modified those two lines. I seem to get the same error hence I tried two equals signs:-

 PHP Parse error: syntax error, unexpected token "="

Its strange how the new php 8 doesn't like this logic. Though actually I have production site 1.58a and its using same php 8.2, and that works with the first code example I put. I guess its clashing with some of the new code somehow on my 2.10 dev site?

27 Feb 2025, 11:05 AM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: setting up attributes file to not show display only in 2.10

HeathenMagic:

Sorry I was a bit vague there. Its includes/modules/attributes.php. I have put the snippet below, its mentioned twice. I know its a developer plugin, it might take them a while to update as they are usually busy. I was curious what the new alternative constant is, if there is one. Bear in mind I have adapted these code snippets to the 2.10 standard, it was working for 1.58a and before, I am aware attributes has been massively reworked so it makes sense it no longer works off the bat:-

// Determine number of attributes associated with this product
$sql = "SELECT count(*) as total
FROM " . TABLE_PRODUCTS_OPTIONS . " popt
LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " patrib ON (popt.products_options_id = patrib.options_id)
WHERE patrib.products_id = :products_id
AND popt.language_id = :language_id
and patrib.attributes_display_only = 0
LIMIT 1";
$sql = $db->bindVars($sql, ':products_id', $_GET['products_id'], 'integer');
$sql = $db->bindVars($sql, ':language_id', $_SESSION['languages_id'], 'integer');
$pr_attr = $db->Execute($sql);

if ($pr_attr->fields['total'] < 1) return;
// Only process the rest of this file if attributes are defined for this product

$prod_id = $_GET['products_id'];
$number_of_uploads = 0;
$zv_display_select_option = 0;
$options_name = $options_menu = $options_html_id = $options_inputfield_id = $options_comment = $options_comment_position = $options_attributes_image = array();
$attributeDetailsArrayForJson = array();

$discount_type = zen_get_products_sale_discount_type((int)$_GET['products_id']);
$discount_amount = zen_get_discount_calc((int)$_GET['products_id']);
$products_price_is_priced_by_attributes = zen_get_products_price_is_priced_by_attributes((int)$_GET['products_id']);

if (PRODUCTS_OPTIONS_SORT_ORDER == '0') {
$options_order_by = " ORDER BY LPAD(popt.products_options_sort_order,11,'0'), popt.products_options_name";
} else {
$options_order_by = ' order by popt.products_options_name';
}

$sql = "SELECT DISTINCT popt.products_options_id, popt.products_options_name, popt.products_options_sort_order,
popt.products_options_type, popt.products_options_length, popt.products_options_comment, popt.products_options_comment_position,
popt.products_options_size,
popt.products_options_images_per_row,
popt.products_options_images_style,
popt.products_options_rows
FROM " . TABLE_PRODUCTS_OPTIONS . " popt
LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " patrib ON (patrib.options_id = popt.products_options_id)
WHERE patrib.products_id= :products_id
AND popt.language_id = :language_id "
and patrib.attributes_display_only == 0 .
$options_order_by;
$sql = $db->bindVars($sql, ':products_id', $_GET['products_id'], 'integer');
$sql = $db->bindVars($sql, ':language_id', $_SESSION['languages_id'], 'integer');
$products_options_names = $db->Execute($sql);


Look at the difference in the above PHP code towards the bottom to what is provided below. While, yes your past code may be similar, as swift pointed out you can see a clear difference in just the color of the code or text. 

I chose to concatenate the new line rather than extend the content within the existing quote. Doing so makes it easier to incorporate changes again in the future using a software comparison tool. 

> **HeathenMagic:**
>
> Sorry I was a bit vague there. Its includes/modules/attributes.php. I have put the snippet below, its mentioned twice. I know its a developer plugin, it might take them a while to update as they are usually busy. I was curious what the new alternative constant is, if there is one. Bear in mind I have adapted these code snippets to the 2.10 standard, it was working for 1.58a and before, I am aware attributes has been massively reworked so it makes sense it no longer works off the bat:-
> 
> ```php
// Determine number of attributes associated with this product
$sql = "SELECT count(*) as total
        FROM " . TABLE_PRODUCTS_OPTIONS . " popt
        LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " patrib ON (popt.products_options_id = patrib.options_id)
        WHERE patrib.products_id = :products_id
        AND popt.language_id = :language_id
	      and      patrib.attributes_display_only = 0 
        LIMIT 1";
$sql = $db->bindVars($sql, ':products_id', $_GET['products_id'], 'integer');
$sql = $db->bindVars($sql, ':language_id', $_SESSION['languages_id'], 'integer');
$pr_attr = $db->Execute($sql);

if ($pr_attr->fields['total'] < 1) return;
// Only process the rest of this file if attributes are defined for this product


$prod_id = $_GET['products_id'];
$number_of_uploads = 0;
$zv_display_select_option = 0;
$options_name = $options_menu = $options_html_id = $options_inputfield_id = $options_comment = $options_comment_position = $options_attributes_image = array();
$attributeDetailsArrayForJson = array();

$discount_type = zen_get_products_sale_discount_type((int)$_GET['products_id']);
$discount_amount = zen_get_discount_calc((int)$_GET['products_id']);
$products_price_is_priced_by_attributes = zen_get_products_price_is_priced_by_attributes((int)$_GET['products_id']);


if (PRODUCTS_OPTIONS_SORT_ORDER == '0') {
    $options_order_by = " ORDER BY LPAD(popt.products_options_sort_order,11,'0'), popt.products_options_name";
} else {
    $options_order_by = ' order by popt.products_options_name';
}

$sql = "SELECT DISTINCT popt.products_options_id, popt.products_options_name, popt.products_options_sort_order,
            popt.products_options_type, popt.products_options_length, popt.products_options_comment, popt.products_options_comment_position,
            popt.products_options_size,
            popt.products_options_images_per_row,
            popt.products_options_images_style,
            popt.products_options_rows
        FROM " . TABLE_PRODUCTS_OPTIONS . " popt
        LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " patrib ON (patrib.options_id = popt.products_options_id)
        WHERE patrib.products_id= :products_id
        AND popt.language_id = :language_id " 
	. "      and      patrib.attributes_display_only = 0 " .
        $options_order_by;
$sql = $db->bindVars($sql, ':products_id', $_GET['products_id'], 'integer');
$sql = $db->bindVars($sql, ':language_id', $_SESSION['languages_id'], 'integer');
$products_options_names = $db->Execute($sql);

Also note I put a space after the zero and before the closing quote. This ensures a gap between the zero and the following "ORDER BY..." code.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Feb 2025, 9:06 PM
#7
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
733
Plugin Contributions:
0

Re: setting up attributes file to not show display only in 2.10

Thanks so much for that. It seems to work with no logs and page is fine! I think I messed up the spacing, I wasn't sure. I need to learn how to use " elements better. I have a lot to learn lol.