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:
Code:
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
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.
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...
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
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...
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
Re: best way to include/require php file w/ zen_get_products_name( function
Code:
$product_info_page = zen_get_handler_from_type(zen_get_products_type((int)$pID)) . '_info';
Re: best way to include/require php file w/ zen_get_products_name( function
Quote:
"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
Re: best way to include/require php file w/ zen_get_products_name( function
Quote:
Originally Posted by
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.