Post by waqasvital » Tue Jun 13, 2017 1:04 pm

I am trying to display sku field on the product page.
I have defined the following in controller>product.php
$data['sku'] = $product_info['sku'];

and following code in view> product.tpl

<?php if ($sku) { ?>
<li>SKU: <?php echo $sku; ?></li>
<?php } ?>

but it still gives Notice: Undefined variable: sku in /home5/uzisport/public_html/.../catalog/view/theme/journal2/template/product/product.tpl on line 301

Please help... where I am doing wrong? Using OC version 2.3.0.2

Newbie

Posts

Joined
Tue Jun 13, 2017 1:00 pm

Post by sdsoftware » Tue Jun 13, 2017 2:23 pm

Try isset()

Code: Select all

<?php if (isset($sku)) { ?>
<li>SKU: <?php echo $sku; ?></li>
<?php } ?>
Also FOR TEST ONLY use
var_dump($product_info[$sku]); in your controller
to check if $sku really has any value

Software Support And Development www.sdware.eu
Ccookie Module || Admin Category/Manufactory/Attribute Filter || Admin Customizer || Bank Tranfer Extended
Business Inquiries Here
My extensions Page Here


User avatar
New member

Posts

Joined
Mon May 29, 2017 3:37 pm


Post by paulfeakins » Tue Jun 13, 2017 5:52 pm

As above, isset() is the one.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by Flazzi » Tue Sep 03, 2019 2:07 pm

sdsoftware -> Great job! I tried everything, looked everywhere but nothing work for OC 2.0.1.

Newbie

Posts

Joined
Fri Dec 15, 2017 2:24 am
Who is online

Users browsing this forum: Majestic-12 [Bot] and 11 guests