Supertex Posted January 28, 2014 Posted January 28, 2014 My product images are named like this p.product_image: "product_1_image-320.jpg" pi.image: "product_1_image-640.jpg" I'm adding the appropriate fields to the admin/categories.php query to 1) Verify large image exists 2) Check that "first" large image name corresponds to image name. 3) Output one of three images to indicate status Should show "cross" for missing large image, "attn" for mismatch, and "check" when large image both exists and corresponds to small image. I don't know how to exclude the last 7 chars of each field in the comparison, so currently will always show "attn.png" <td align="center"> <?php if (is_null($products['image'])) { echo tep_image(DIR_WS_IMAGES . 'cross.png', 10, 10); } else { if (($products['image'] != $products['products_image']) && ($products['sort_order'] == '1')); { echo tep_image(DIR_WS_IMAGES . 'attn.png', 10, 10); } else { echo tep_image(DIR_WS_IMAGES . 'check.png', 10, 10); } } ?> Point me in the right direction? osC v2.3.1 MySQL v8.0.32 PHP v5.6.40 Installed addons: . Attribute Sets Plus .. Create Account & Manual Order Maker .. Customer Testimonials 2.3.4 .. Customer Blacklist .. Dynamic Info Pages .. FedEx Web Svcs v9 .. Filtered Sales Report .. Generic Box .. Google XML Sitemap SEO .. Maximum Order Value .. Modular Front Page .. Monthly Sales & Tax Report .. Multiple Products Manager .. Must Accept Terms & Conditions .. Order Editior .. PDF Customer Invoice .. Price in Cart Only .. Product Sort/Order .. Product Sort in Cart .. Quantity Discounts .. Restrict Delivery Methods .. SEO Header Tags - Reloaded .. Separate Pricing Per Customer .. Simpler Admin Session Length Control .. Sitemap SEO .. Show Free Ship + Modules .. Specials by Category for SPPC .. Store Mode (open|closed|maintenance) .. Store Pickup Shipping .. Theme Switcher .. Ultimate SEO URLs 5 Pro .. UPS XML Rates & Svcs 1.4 .. USPS methods 7.3.1 .. Who's Online Dashboard . Fixes: Add to cart -> 'product not found' : FIX Login issues with IE 11 : FIX Tools: Incredibly Handy: osC Xref
Jack_mcs Posted January 28, 2014 Posted January 28, 2014 You get part of the name like this substr($products['products_image'], 0, -7); You should verify the variable exists before doing that. I don't know if the code you show is real code or not but the semi-colon after the second if statement will cause a failure. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
Supertex Posted January 28, 2014 Author Posted January 28, 2014 @@Jack_mcs Thank you so very much. <?php if (is_null($products['image'])) { echo tep_image(DIR_WS_IMAGES . 'cross.png', 10, 10); } else { if ((substr($products['image'], 0, -7)) != (substr($products['products_image'], 0, -7))) { echo tep_image(DIR_WS_IMAGES . 'attn.png', 10, 10); } else { echo tep_image(DIR_WS_IMAGES . 'check.png', 10, 10); } } ?> This works. I had to define an exclusion in the query for "WHERE pi.sort_order IS NULL or pi.sort_order <2" in order to prevent duplicate product lines for any product with more than one large image. Is that what you mean by "verify the variable exists"? Or are you talking about another statement? ..."is_set" or something? Forgive me, I'm nowhere near competent for this, really. osC v2.3.1 MySQL v8.0.32 PHP v5.6.40 Installed addons: . Attribute Sets Plus .. Create Account & Manual Order Maker .. Customer Testimonials 2.3.4 .. Customer Blacklist .. Dynamic Info Pages .. FedEx Web Svcs v9 .. Filtered Sales Report .. Generic Box .. Google XML Sitemap SEO .. Maximum Order Value .. Modular Front Page .. Monthly Sales & Tax Report .. Multiple Products Manager .. Must Accept Terms & Conditions .. Order Editior .. PDF Customer Invoice .. Price in Cart Only .. Product Sort/Order .. Product Sort in Cart .. Quantity Discounts .. Restrict Delivery Methods .. SEO Header Tags - Reloaded .. Separate Pricing Per Customer .. Simpler Admin Session Length Control .. Sitemap SEO .. Show Free Ship + Modules .. Specials by Category for SPPC .. Store Mode (open|closed|maintenance) .. Store Pickup Shipping .. Theme Switcher .. Ultimate SEO URLs 5 Pro .. UPS XML Rates & Svcs 1.4 .. USPS methods 7.3.1 .. Who's Online Dashboard . Fixes: Add to cart -> 'product not found' : FIX Login issues with IE 11 : FIX Tools: Incredibly Handy: osC Xref
Jack_mcs Posted January 28, 2014 Posted January 28, 2014 In your first if statement, you check to see if the 'image' variable is empty. In the second if statement, you don't need to check that variable since the first check covers it. But you don't check if 'products_image' is null. It will work as it is but that oversight is the kind that creates problems later on. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons
MrPhil Posted January 28, 2014 Posted January 28, 2014 <?php if (is_null($products['image'])) { echo tep_image(DIR_WS_IMAGES . 'cross.png', 10, 10); } else { if (!isset($products['products_image']) || substr($products['image'], 0, -7) != substr($products['products_image'], 0, -7)) { echo tep_image(DIR_WS_IMAGES . 'attn.png', 10, 10); } else { echo tep_image(DIR_WS_IMAGES . 'check.png', 10, 10); } } ?> If products_image doesn't exist, it won't try to do a substr() on it ("short circuiting").
Supertex Posted January 31, 2014 Author Posted January 31, 2014 So this should cover me, ya? <?php if (is_null($products['products_image'])) { echo tep_image(DIR_WS_IMAGES . 'cross.png', SMALL_IMAGE_STATUS_MISSING, 10, 10); } else { if (is_null($products['image'])) { echo tep_image(DIR_WS_IMAGES . 'attn.png', LARGE_IMAGE_STATUS_MISSING, 10, 10); } else { if ((substr($products['image'], 0, -7)) != (substr($products['products_image'], 0, -7))) { echo tep_image(DIR_WS_IMAGES . 'attn2.png', LARGE_IMAGE_STATUS_MISMATCH, 10, 10); } else { echo tep_image(DIR_WS_IMAGES . 'check.png', LARGE_IMAGE_STATUS_GOOD, 10, 10); } } } ?> osC v2.3.1 MySQL v8.0.32 PHP v5.6.40 Installed addons: . Attribute Sets Plus .. Create Account & Manual Order Maker .. Customer Testimonials 2.3.4 .. Customer Blacklist .. Dynamic Info Pages .. FedEx Web Svcs v9 .. Filtered Sales Report .. Generic Box .. Google XML Sitemap SEO .. Maximum Order Value .. Modular Front Page .. Monthly Sales & Tax Report .. Multiple Products Manager .. Must Accept Terms & Conditions .. Order Editior .. PDF Customer Invoice .. Price in Cart Only .. Product Sort/Order .. Product Sort in Cart .. Quantity Discounts .. Restrict Delivery Methods .. SEO Header Tags - Reloaded .. Separate Pricing Per Customer .. Simpler Admin Session Length Control .. Sitemap SEO .. Show Free Ship + Modules .. Specials by Category for SPPC .. Store Mode (open|closed|maintenance) .. Store Pickup Shipping .. Theme Switcher .. Ultimate SEO URLs 5 Pro .. UPS XML Rates & Svcs 1.4 .. USPS methods 7.3.1 .. Who's Online Dashboard . Fixes: Add to cart -> 'product not found' : FIX Login issues with IE 11 : FIX Tools: Incredibly Handy: osC Xref
Supertex Posted January 31, 2014 Author Posted January 31, 2014 heh...the "code" box and I don't seem to get along. osC v2.3.1 MySQL v8.0.32 PHP v5.6.40 Installed addons: . Attribute Sets Plus .. Create Account & Manual Order Maker .. Customer Testimonials 2.3.4 .. Customer Blacklist .. Dynamic Info Pages .. FedEx Web Svcs v9 .. Filtered Sales Report .. Generic Box .. Google XML Sitemap SEO .. Maximum Order Value .. Modular Front Page .. Monthly Sales & Tax Report .. Multiple Products Manager .. Must Accept Terms & Conditions .. Order Editior .. PDF Customer Invoice .. Price in Cart Only .. Product Sort/Order .. Product Sort in Cart .. Quantity Discounts .. Restrict Delivery Methods .. SEO Header Tags - Reloaded .. Separate Pricing Per Customer .. Simpler Admin Session Length Control .. Sitemap SEO .. Show Free Ship + Modules .. Specials by Category for SPPC .. Store Mode (open|closed|maintenance) .. Store Pickup Shipping .. Theme Switcher .. Ultimate SEO URLs 5 Pro .. UPS XML Rates & Svcs 1.4 .. USPS methods 7.3.1 .. Who's Online Dashboard . Fixes: Add to cart -> 'product not found' : FIX Login issues with IE 11 : FIX Tools: Incredibly Handy: osC Xref
MrPhil Posted January 31, 2014 Posted January 31, 2014 So this should cover me, ya? It should work, but only you know what you want to accomplish and whether the code is working right. You've changed the logic quite a bit.
Supertex Posted May 4, 2014 Author Posted May 4, 2014 I found a minor bug in this snippet. It seems that when I create a product without an image, NULL is entered in the field. However, when I copy that same product as new (to edit values later) NULL is not entered for that or any following copies. The end result is that my code, which should show me a red "X" when a product's small image is missing, only shows the "X" for the original product. It seems my code only checks for NULL entries and I'm not sure how to have it check for an empty field. I'm assuming something like: <?php if (is_null || ''($products['products_image'])) { echo tep_image(DIR_WS_IMAGES . 'cross.png', SMALL_IMAGE_STATUS_MISSING, 10, 10); } else { if (is_null || '' ($products['image'])) { echo tep_image(DIR_WS_IMAGES . 'attn.png', LARGE_IMAGE_STATUS_MISSING, 10, 10); } else { if ((substr($products['image'], 0, -7)) != (substr($products['products_image'], 0, -7))) { echo tep_image(DIR_WS_IMAGES . 'attn2.png', LARGE_IMAGE_STATUS_MISMATCH, 10, 10); } else { echo tep_image(DIR_WS_IMAGES . 'check.png', LARGE_IMAGE_STATUS_GOOD, 10, 10); } } } ?> This, however did not work. What am I doing wrong? osC v2.3.1 MySQL v8.0.32 PHP v5.6.40 Installed addons: . Attribute Sets Plus .. Create Account & Manual Order Maker .. Customer Testimonials 2.3.4 .. Customer Blacklist .. Dynamic Info Pages .. FedEx Web Svcs v9 .. Filtered Sales Report .. Generic Box .. Google XML Sitemap SEO .. Maximum Order Value .. Modular Front Page .. Monthly Sales & Tax Report .. Multiple Products Manager .. Must Accept Terms & Conditions .. Order Editior .. PDF Customer Invoice .. Price in Cart Only .. Product Sort/Order .. Product Sort in Cart .. Quantity Discounts .. Restrict Delivery Methods .. SEO Header Tags - Reloaded .. Separate Pricing Per Customer .. Simpler Admin Session Length Control .. Sitemap SEO .. Show Free Ship + Modules .. Specials by Category for SPPC .. Store Mode (open|closed|maintenance) .. Store Pickup Shipping .. Theme Switcher .. Ultimate SEO URLs 5 Pro .. UPS XML Rates & Svcs 1.4 .. USPS methods 7.3.1 .. Who's Online Dashboard . Fixes: Add to cart -> 'product not found' : FIX Login issues with IE 11 : FIX Tools: Incredibly Handy: osC Xref
Supertex Posted May 4, 2014 Author Posted May 4, 2014 For anyone else that might use this, this fixed it: <?php if ((is_null($products['products_image'])) || (($products['products_image']==""))) { echo tep_image(DIR_WS_IMAGES . 'cross.png', SMALL_IMAGE_STATUS_MISSING, 10, 10); } else { if (is_null($products['image'])) { echo tep_image(DIR_WS_IMAGES . 'attn.png', LARGE_IMAGE_STATUS_MISSING, 10, 10); } else { if ((substr($products['image'], 0, -7)) != (substr($products['products_image'], 0, -7))) { echo tep_image(DIR_WS_IMAGES . 'attn2.png', LARGE_IMAGE_STATUS_MISMATCH, 10, 10); } else { echo tep_image(DIR_WS_IMAGES . 'check.png', LARGE_IMAGE_STATUS_GOOD, 10, 10); } } } ?> osC v2.3.1 MySQL v8.0.32 PHP v5.6.40 Installed addons: . Attribute Sets Plus .. Create Account & Manual Order Maker .. Customer Testimonials 2.3.4 .. Customer Blacklist .. Dynamic Info Pages .. FedEx Web Svcs v9 .. Filtered Sales Report .. Generic Box .. Google XML Sitemap SEO .. Maximum Order Value .. Modular Front Page .. Monthly Sales & Tax Report .. Multiple Products Manager .. Must Accept Terms & Conditions .. Order Editior .. PDF Customer Invoice .. Price in Cart Only .. Product Sort/Order .. Product Sort in Cart .. Quantity Discounts .. Restrict Delivery Methods .. SEO Header Tags - Reloaded .. Separate Pricing Per Customer .. Simpler Admin Session Length Control .. Sitemap SEO .. Show Free Ship + Modules .. Specials by Category for SPPC .. Store Mode (open|closed|maintenance) .. Store Pickup Shipping .. Theme Switcher .. Ultimate SEO URLs 5 Pro .. UPS XML Rates & Svcs 1.4 .. USPS methods 7.3.1 .. Who's Online Dashboard . Fixes: Add to cart -> 'product not found' : FIX Login issues with IE 11 : FIX Tools: Incredibly Handy: osC Xref
Recommended Posts
Archived
This topic is now archived and is closed to further replies.