Forums / All Other Contributions/Addons / Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Views: 660,384

Results 3,581 to 3,600 of 3,609
7 Jul 2024, 3:06 PM
#3581
mc12345678 avatar

mc12345678

Totally Zenned

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

Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Question asked elsewhere relates to adding other SBA created fields to product searches. For example, there is a description field added to the admin area and the user would like to have that content searchable.

A while back a new auto loading observer class was added to the catalog side to support searching the custom ID. This can be further modified to include other SBA/PWAS fields.

The file in question is: includes/classes/observers/auto.advanced_search_categories_custom_id.php

A duplicate file name could possibly be created for the additional content but also the file name could be changed. Really would suggest making good notes in the file.

Anyways, around line 166, there is/ was this code:

          $where_str .= "OR p.products_id 
                                           IN (SELECT products_id 
                                                FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " 
                                           WHERE customid LIKE '%:keywords%')";

The permalink was: https://github.com/mc12345678/Stock_By_Attributes_Combined/blob/76623dec62fc1f133d68afd64295ab6d5967c30f/includes/classes/observers/auto.advanced_search_categories_custom_id.php#L166-L169

Anyway, that snippet specifically retrieves product ids that have a custom ID containing or like the keywords searched.

Data in the SBA/PWAS table can be added to that parenthetical group for searching. I would suggest though adding an alias to the table to prevent potential version differences from bringing out some sort of conflict.

So first would change that to:

          $where_str .= "OR p.products_id 
                                           IN (SELECT products_id 
                                                FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                                           WHERE pwas.customid LIKE '%:keywords%')";

Then to aid in expansion I would break some of the content so that endings are on their own line. This way, new code is both easier to add and easier to find when added.

          $where_str .= "OR p.products_id 
                                           IN (SELECT products_id 
                                                FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                                           WHERE 
                                               pwas.customid LIKE '%:keywords%'
               ) 
               ";

And then add the requested information:

          $where_str .= "OR p.products_id 
                                           IN (SELECT products_id 
                                                FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                                           WHERE 
                                               pwas.customid LIKE '%:keywords%'
                                               OR pwas.title LIKE '%:keywords%'
               ) 
               ";

I note that while in the admin screen the column is shown as a description, the database field name was title and also that the base installation supports basically 100 characters.

I'm also aware others have added fields to that table in support of whatever additional features they've added. I would expect a similar error to include those additional fields in the search.

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

7 Jul 2024, 6:17 PM
#3582
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

mc12345678:

Question asked elsewhere relates to adding other SBA created fields to product searches. For example, there is a description field added to the admin area and the user would like to have that content searchable.

A while back a new auto loading observer class was added to the catalog side to support searching the custom ID. This can be further modified to include other SBA/PWAS fields.

The file in question is: includes/classes/observers/auto.advanced_search_categories_custom_id.php

A duplicate file name could possibly be created for the additional content but also the file name could be changed. Really would suggest making good notes in the file.

Anyways, around line 166, there is/ was this code:

      $where_str .= "OR p.products_id 
                                       IN (SELECT products_id 
                                            FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " 
                                       WHERE customid LIKE '%:keywords%')";
> 
> The permalink was: <https://github.com/mc12345678/Stock_By_Attributes_Combined/blob/76623dec62fc1f133d68afd64295ab6d5967c30f/includes/classes/observers/auto.advanced_search_categories_custom_id.php#L166-L169>
> 
> Anyway, that snippet specifically retrieves product ids that have a custom ID containing or like the keywords searched. 
> 
> Data in the SBA/PWAS table can be added to that parenthetical group for searching. I would suggest though adding an alias to the table to prevent potential version differences from bringing out some sort of conflict. 
> 
> So first would change that to: 
> ```
          $where_str .= "OR p.products_id 
                                           IN (SELECT products_id 
                                                FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                                           WHERE pwas.customid LIKE '%:keywords%')";

Then to aid in expansion I would break some of the content so that endings are on their own line. This way, new code is both easier to add and easier to find when added.

      $where_str .= "OR p.products_id 
                                       IN (SELECT products_id 
                                            FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                                       WHERE 
                                           pwas.customid LIKE '%:keywords%'
           ) 
           ";
> 
> And then add the requested information: 
> 
> ```
          $where_str .= "OR p.products_id 
                                           IN (SELECT products_id 
                                                FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
                                           WHERE 
                                               pwas.customid LIKE '%:keywords%'
                                               OR pwas.title LIKE '%:keywords%'
               ) 
               ";

I note that while in the admin screen the column is shown as a description, the database field name was title and also that the base installation supports basically 100 characters.

I'm also aware others have added fields to that table in support of whatever additional features they've added. I would expect a similar error to include those additional fields in the search.

Are the code changes that you recommend required to get the search to work?

7 Jul 2024, 8:40 PM
#3583
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

jodean:

Are the code changes that you recommend required to get the search to work?

To use/reuse the existing code intended to offer search of SBA data, yes at least the last change was needed. The operation can be accomplished any number of other ways and may depend on other installed software.

The above fix or addition adds the search capability that was requested in another separate thread of wanting to search the SBA description.

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

5 Sep 2024, 3:55 PM
#3584
chuckrey avatar

chuckrey

Zen Follower

Join Date:
Aug 2020
Location:
Richarson
Posts:
160
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

mc12345678:

So, I went back to review the modification I applied. There was an issue with the query I created, it had an extra semi-colon from when I copied and pasted it from within phpMyAdmin.

The issues about the missing constant, well that is something that would be seen with the code in place, visitors navigating the site until the database install was completed. I've made generated a change to the code to prevent logging that issue; however, in a way the fix is unnecessary once the appropriate constant has been set either in a file or the database.

But, the other above issues? I have no idea how the other issues exist in your file. I do not see github history of the problem content like:

  1. I don't see what the issue is with the option list, the three options appear to have the same format with just differences in associated/necessary data. So i'm not sure what issue is/was created there.
  2. semi-colons as a part of case statements, these specifically are supposed to be colons, there is nothing that I found having semi-colons in that spot.

I have created and force pushed an update for the original issue for the query to do what was requested: Adds all new product/attribute pairs for single attribute not yet in SBA · mc12345678/Stock_By_Attributes_Combined@064350f (github.com)

https://github.com/mc12345678/Stock_By_Attributes_Combined/commit/064350fe3a19a5c8d18ac921e4326c26a8192f01

I am reaching out because I thought this error (missing constant) was resolved, but it is still arriving. I am not clear on specifically what I need to do when you say "once the appropriate constant has been set either in a file or the database". Can you please advise what I need to do to resolve? I saw the updated install file and updated, but am not sure if that is all that needed to be done to resolve the missing constant. Thank you so much.

5 Sep 2024, 5:32 PM
#3585
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

chuckrey:

I am reaching out because I thought this error (missing constant) was resolved, but it is still arriving. I am not clear on specifically what I need to do when you say "once the appropriate constant has been set either in a file or the database". Can you please advise what I need to do to resolve? I saw the updated install file and updated, but am not sure if that is all that needed to be done to resolve the missing constant. Thank you so much.

No problem.

The issue of the missing constant is expected to be non-existent upon installation of the software in an operational state. The purest state would be to:

  1. have a base Zen Cart package,
  2. load the SBA files from github merging the template changes as necessary for that additional template functionality
  3. log into your admin
  4. change the url path to access: stock_by_attr_install.php.

For ZC 1.5.8, that would be like: mydomain/MYADMIN/index.php?cmd=stock_by_attr_install
The installation file can also be executed by mydomain/MYADMIN/stock_by_attr_install.php

  1. Once see the generated window (in ZC 2.X may also have a message across the header and a debug log generated indicating an issue with the header), in the dropdown at the top of the screen select: Full/Upgrade DB Install
  2. press the button to run the script.

This will add/create the constant that is missing (PRODUCTS_OPTIONS_TYPE_SELECT_SBA).

If there are other files laying around in the installation then those may be the one(s) generating the logs.

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

5 Sep 2024, 7:46 PM
#3586
chuckrey avatar

chuckrey

Zen Follower

Join Date:
Aug 2020
Location:
Richarson
Posts:
160
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

mc12345678:

No problem.

The issue of the missing constant is expected to be non-existent upon installation of the software in an operational state. The purest state would be to:

  1. have a base Zen Cart package,
  2. load the SBA files from github merging the template changes as necessary for that additional template functionality
  3. log into your admin
  4. change the url path to access: stock_by_attr_install.php.

For ZC 1.5.8, that would be like: mydomain/MYADMIN/index.php?cmd=stock_by_attr_install
The installation file can also be executed by mydomain/MYADMIN/stock_by_attr_install.php

  1. Once see the generated window (in ZC 2.X may also have a message across the header and a debug log generated indicating an issue with the header), in the dropdown at the top of the screen select: Full/Upgrade DB Install
  2. press the button to run the script.

This will add/create the constant that is missing (PRODUCTS_OPTIONS_TYPE_SELECT_SBA).

If there are other files laying around in the installation then those may be the one(s) generating the logs.

Ah, okay. I missed the last and most important step. Just completed. Thanks yet again!

5 Feb 2025, 3:50 PM
#3587
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

What are the table names that are created for this plugin?

5 Feb 2025, 4:21 PM
#3588
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Is there any way to thoroughly uninstall this module?

5 Feb 2025, 4:35 PM
#3589
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

jodean:

What are the table names that are created for this plugin?

They are listed in each of includes/extra_datafiles/products_with_attributes_stock_database_tables.php and admin/includes/extra_datafiles/products_with_attributes_stock.php

As being:

define('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK', DB_PREFIX . 'products_with_attributes_stock');
define('TABLE_ORDERS_PRODUCTS_ATTRIBUTES_STOCK', DB_PREFIX . 'orders_products_attributes_stock');
define('TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK_ATTRIBUTES_NON_STOCK', DB_PREFIX . 'products_with_attributes_stock_attributes_non_stock');

The value of DB_PREFIX is identified in your applicable configure.php file.

The information on the right side of each above define makes up the table name. So, if your DB_PREFIX is zen_, then the first table would be zen_products_with_attributes_stock.

Those tables are created through the admin file: stock_by_attr_install.php

There are or might be other tables that are touched. Since the reason for asking hasn't been identified I haven't gone to find which are so touched and further not making assumptions about the intent. I expect that the script to install or remove would do or undo whatever issue is at hand.

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

2 May 2025, 6:02 PM
#3590
chuckrey avatar

chuckrey

Zen Follower

Join Date:
Aug 2020
Location:
Richarson
Posts:
160
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I really like this plugin and it works perfect for my use. I am currently using 1.5.8a on a furniture distributor website. I am looking to move to 2.1.0 soon. I understand there is an attribute stock native to the most recent release of 2.1.0. Can someone tell me if it's much different than SBA and/or any limitations? If anyone has a site to share showing it in action, that would be awesome too just to give me an idea. Thanks!

2 May 2025, 6:12 PM
#3591
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,844
Plugin Contributions:
17

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

POSM is an included part of 2.1.0 with a built-in convertor which enables the move to POSM. You can read some about it at https://docs.zen-cart.com/user/running/posm/

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

5 May 2025, 1:41 PM
#3592
chuckrey avatar

chuckrey

Zen Follower

Join Date:
Aug 2020
Location:
Richarson
Posts:
160
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

dbltoe:

POSM is an included part of 2.1.0 with a built-in convertor which enables the move to POSM. You can read some about it at https://docs.zen-cart.com/user/running/posm/

I will have a good look. Thx

11 Jun 2025, 9:14 AM
#3593
cefyn avatar

cefyn

New Zenner

Join Date:
May 2007
Posts:
87
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I am using pwas version 1.5.4 with zen cart 1.5.7c, Easy Populate 4.0.39.ZC - 06-17-2024 and Bootstrap 4.I’ve been using PWAS a lot recently, and the problem I have is that admin/products with attributes stock.php keeps disappearing from the server, and, consequently, PWAS itself disappears from admin home. I re-uploaded the file last night, everything was working as it should, and this morning it had gone again. It’s the only file affected, and I can’t find anything in my logs about it. It will work for a few hours, then disappear again. My paypal modules disappeared from admin recently, and were restored after removing a php error in another payment module, so I imagine something similar is going on with this. Has anyone got any ideas as to where I should start looking? Thanks.

11 Jun 2025, 11:39 AM
#3594
jeking avatar

jeking

Totally Zenned

Join Date:
Oct 2005
Location:
Chicago, IL USA
Posts:
1,592
Plugin Contributions:
0

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

cefyn:

I am using pwas version 1.5.4 with zen cart 1.5.7c, Easy Populate 4.0.39.ZC - 06-17-2024 and Bootstrap 4.I’ve been using PWAS a lot recently, and the problem I have is that admin/products with attributes stock.php keeps disappearing from the server, and, consequently, PWAS itself disappears from admin home. I re-uploaded the file last night, everything was working as it should, and this morning it had gone again. It’s the only file affected, and I can’t find anything in my logs about it. It will work for a few hours, then disappear again. My paypal modules disappeared from admin recently, and were restored after removing a php error in another payment module, so I imagine something similar is going on with this. Has anyone got any ideas as to where I should start looking? Thanks.

Check with your hosting company. I've had one file from Stock by Attribute that kept getting flagged as malware. The server would then move the file to quarantine. I had to set up a rule to exclude it from the scanner.

Jim
Wheaton Website Services

12 Jun 2025, 9:30 AM
#3595
cefyn avatar

cefyn

New Zenner

Join Date:
May 2007
Posts:
87
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Thanks. I've checked with the hosting company, and they can see it disappears for no reason, but they can't pinpoint the exact cause. It's not showing in any of their quarantine logs. They've enabled enhanced logging to try and pinpoint the cause, and I've sent them the file for them to try and duplicate the problem at their end. Fingers crossed.

13 Jun 2025, 12:32 PM
#3596
cefyn avatar

cefyn

New Zenner

Join Date:
May 2007
Posts:
87
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

The hosting company have replied, "We've confirmed that the file products_with_attributes_stock.php is being repeatedly flagged by ClamAV with the rule YARA.eval_post.UNOFFICIAL. This is causing the system to either quarantine or remove it as part of routine malware scans."
The only solution they offer me is to go on a VPS where I can configure the virus scanner myself, so I'll just upload it when I need it for now. At least I know what's happening now, thanks jeking.

13 Jun 2025, 6:58 PM
#3597
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,844
Plugin Contributions:
17

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Your hosting company should be able to exclude the file from ClamAV. It's a simple process for them.

If they don't know how, you might want to look elsewhere.

Can you access your etc folder? If so, look for etc/clamav/clamd.conf

You can add ```
ExcludePath /path/to/your/safe/file


You will probably have to rely on your host to restart, if you can change the file yourself.

@MC# - if the file is known to be good, why not let ClamAV know with a [False Positive Submission](https://www.clamav.net/reports/fp)?

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

14 Jun 2025, 7:31 PM
#3598
cefyn avatar

cefyn

New Zenner

Join Date:
May 2007
Posts:
87
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

They have excluded it from the scan now, with some reservation.
"However, please note that excluding files from antivirus scans is not considered a best practice, as it may pose security risks. We strongly advise reviewing the file to ensure it does not contain any content that could trigger scans."
Can anyone tell me the best way to do this?

14 Jun 2025, 9:01 PM
#3599
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,844
Plugin Contributions:
17

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

Perhaps you need to familiarize your host with the wonders of a google search.:P

When ClamAV quarantines a file, the host can run clamscan on the specific file in the quarantine directory. Running clamscan on the specific file will let them know the reason.

JSYK, ClamAV is a free program. We have found that Imunify360 is far superior and use it on our servers.

You can download a Windows version at clamav.net/downloads. If it quarantines the file, the reason will be in the quarantine subfolder with the filename as part of the log filename.

Open the PHP file in a secure environment (e.g., a text editor on a sandboxed system) and look for suspicious patterns, such as:

  • Obfuscated code using base64_decode, eval, gzinflate, or str_replace.
  • Functions like exec, system, or shell_exec that could indicate a backdoor.
  • Unusual includes or external URL references.

Not having a copy of the file, that's the best advice I can give.

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.
Zen Cart Certified hosting at myZenCartHost.com

15 Jun 2025, 8:21 AM
#3600
cefyn avatar

cefyn

New Zenner

Join Date:
May 2007
Posts:
87
Plugin Contributions:
1

Re: Stock by Attribute v4.0 addon for v1.3.5-1.3.9

I’m afraid I can’t get the latest clamav to run on my computer, out of date OS, sorry. Just in case you’re interested, the file is Stock_By_Attributes_Combined- master\admin\products_with_attributes_stock.php from https://github.com/mc12345678/Stock_By_Attributes_Combined