Zen Cart Logo
Forums / Code Collaboration / best way to include/require php file w/ zen_get_products_name( function

best way to include/require php file w/ zen_get_products_name( function

Views: 4,623

Results 1 to 9 of 9
27 Mar 2018, 22:17
#1
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

best way to include/require php file w/ zen_get_products_name( function

I'm working on a custom report in the admin to list in a table links to products that have no pictures or have "no_image.jpg" as the image name...

basically every time I try something like:

require(DIR_WS_FUNCTIONS . 'general.php');  //for zen_get_products_name
include DIR_FS_CATALOG . 'includes/functions/functions_lookups.php'; //for zen_get_products_name

i get... PHP Fatal error: Cannot redeclare ... some function

I do start my php file with...

require('includes/application_top.php');

aside from the ol' copy n' paste how can I include/require this function?

I should probably just spend some time reading through wiki developers api, but haven't yet, if anyone has an advised reading in that feel free to suggest it.

Thanks,
b

27 Mar 2018, 22:27
#2
mesnitu avatar

mesnitu

Totally Zenned

Join Date:
Aug 2014
Location:
Lisbon
Posts:
597
Plugin Contributions:
0

Re: best way to include/require php file w/ zen_get_products_name( function

And the log file, what does it say?

Also, have you considered using EP4 to export , and with libreoffice calc or Excel , filter the images by "no-image.jpg" ?
If that's the intention, its much easier to filter , work the the missing images, and reupload / update the products.

27 Mar 2018, 23:46
#3
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: best way to include/require php file w/ zen_get_products_name( function

The zen_get_products_name function is already accessible to the admin and needs no further include/require. So in this case, the answer to the question is what has already been done: includes/require includes/application_top.php

You can also use the admin's tools->developer's toolkit to search the admin side for the function's use on the admin side for such situations to see if/how it was implemented.

As mesnitu suggested there are multiple ways to go about it, even if to take a plugin that looks for product that have an image link to a non-existent image and in a way reversing the logic. Instead of collecting all of the images, collect all of the product...

27 Mar 2018, 23:59
#4
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

Re: best way to include/require php file w/ zen_get_products_name( function

I use EasyPopulate, and that is a totally acceptable way to do what I'm trying to do, but I'm sadistic and trying to learn to code better. (:

Plus I'm creating a one page "errant products" report that runs various queries like if cost is greater than price, etc.

So if I add
include DIR_FS_CATALOG . 'includes/functions/functions_lookups.php'; //for zen_get_products_name

i get...

PHP Fatal error: Cannot redeclare zen_get_countries() (previously declared in /home/content/blah/blah/html/admin/includes/functions/general.php:822

PHP Fatal error: Cannot redeclare zen_redirect() (previously declared in /blahblahblah/admin/includes/functions/general.php:12

28 Mar 2018, 00:48
#5
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: best way to include/require php file w/ zen_get_products_name( function

Not sure if you missed my post or if it was confusing.If the function you are wanting to use is zen_get_products_name, then you only need to include "includes/application_top.php" prior to calling it.If there is some other function desired to be used, then please either identify the function or the desired result to be obtained.As for the admin's general.php function file, that is already included (along with all of the other ZC default function files found in admin/includes/functions). That means you do not need to uniquely include that or any other default ZC admin function file...

28 Mar 2018, 01:43
#6
wolfderby avatar

wolfderby

Zen Follower

Join Date:
Dec 2008
Location:
Pittsburgh, PA
Posts:
241
Plugin Contributions:
0

Re: best way to include/require php file w/ zen_get_products_name( function

If I don't include anything I get...

PHP Fatal error: Call to undefined function zen_get_info_page()

which is defined in includes/functions/functions_lookups.php

28 Mar 2018, 02:08
#7
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: best way to include/require php file w/ zen_get_products_name( function

$product_info_page = zen_get_handler_from_type(zen_get_products_type((int)$pID)) . '_info';
28 Mar 2018, 08:29
#8
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,866
Plugin Contributions:
7

Re: best way to include/require php file w/ zen_get_products_name( function

"list in a table links to products that have no pictures or have "no_image.jpg"
You may be re-inventing the wheel:
https://github.com/torvista/Image-Checker

01 Apr 2018, 19:00
#9
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,953
Plugin Contributions:
8

Re: best way to include/require php file w/ zen_get_products_name( function

wolfderby:

If I don't include anything I get...

PHP Fatal error: Call to undefined function zen_get_info_page()

which is defined in includes/functions/functions_lookups.php

welcome to the wonderful world of ZC functions.

you are working on a custom report on the admin side. the undefined function is on the catalog side. some functions are only on 1 side, and not the other; some functions are the same; and some functions with the same name are different on both sides. oy!

you need to figure out which functions from the catalog side you need and somehow only include those.... or some other coding hocus pocus...

this is an issue that will hopefully get resolved in future releases of ZC.

best.