Post by hotwebideas » Fri Jul 08, 2011 7:26 pm

Today, I came across a problem that was silently bugging me for the past week and that is that when I am editing a product in the admin system, I sometimes forget what product I am editing. With over 500 products, you can easily get lost. The problem is that Open Cart does not show you the product name while you are editing in one of its many tabs including "Data", "Link", and "Design". It just says "Product". I would like it show the name of the product that I am editing wherever I am. I went to work to make that happen and solve this problem.

You only need to add 4 lines of code to the \admin\controller\catalog\product.php

Code: Select all

$this->data['product_title'] = $this->language->get('product_title'); // Initiate the product_title variable for the view when entering a new product.
if(isset($this->request->get['product_id']))
{
    $this->data['product_title'] = $this->data['product_description'][1]['name']; // Change the product_title variable for the view if we are editing an existing product.
}
You also need to add that variable to the view at admin\view\template\catalog\product_form.tpl

Code: Select all

<?php echo $heading_title . ": $product_title"; ?>
Editing the view is quick and only takes one line.

Look for the line of code with <?php echo $heading_title towards the top. You simply add your $product_title variable that you set up in the controller.

That is it! Your product title will now display.

If you notice in my controller code, I am reference the language file, which is optional and that simply shows "New Product" when you are adding a new product, but you will need to add that entry to your language file at \admin\language\english\catalog\product.php - This is optional and you can change the first line in the controller code to $this->data['product_title'] = "New Product"; and bypass the language file if you want.

I also have written more details on this on my hub at http://hubpages.com/hub/OpenCart-Ecomme ... min-screen

Bruce

New member

Posts

Joined
Wed Jun 29, 2011 11:44 pm

Post by Geodas81 » Sun Feb 16, 2020 6:52 pm

I know that the topic is 9 years old but is there a same solution for opencart 3.0.3.2???

Newbie

Posts

Joined
Fri Nov 08, 2019 8:26 pm

Post by straightlight » Sun Feb 16, 2020 9:54 pm

9 years old ... desperate times for desperate measures store owners says ...

Change all instances of $this->data to: $data

Then, in your TWIG file, simply use:

Code: Select all

{{ heading_title }}: {{ product_title }}
This should resolved the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by agatha65 » Mon Feb 17, 2020 12:23 am

For OC 3

Attachments

Last edited by agatha65 on Mon Feb 17, 2020 9:05 am, edited 1 time in total.

Suppliers Module - XML, CSV, XLS Product Feed Import and Update
Rich Snippets | Facebook Open Graph Meta Tags | WebP Images
Image


User avatar
Active Member

Posts

Joined
Fri Mar 16, 2012 10:18 am
Location - Canada, QC

Post by straightlight » Mon Feb 17, 2020 1:29 am

agatha65 wrote:
Mon Feb 17, 2020 12:23 am
For OC 3
<?php if ($product_name) { ?>
<h3 class="panel-title"><i class="fa fa-pencil"></i> <a href="{{ product_href }}" target="_blank">{{ product_name }}&nbsp;<i class="fa fa-external-link"></i></a></h3>
<?php } ?>
Won't work with PHP tags unless using the Template Switcher.

Code: Select all

<?php if ($product_name) { ?>
for:

Code: Select all

{% if product_name %}
and:

Code: Select all

<?php } ?>
for:

Code: Select all

{% endif %}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by agatha65 » Mon Feb 17, 2020 9:09 am

Oops, my bad!
I ported it from OC2.
It is fixed now.

Suppliers Module - XML, CSV, XLS Product Feed Import and Update
Rich Snippets | Facebook Open Graph Meta Tags | WebP Images
Image


User avatar
Active Member

Posts

Joined
Fri Mar 16, 2012 10:18 am
Location - Canada, QC

Post by Geodas81 » Mon Feb 17, 2020 3:10 pm

I download the extension but i got error when i go to products tab.

Code: Select all

Parse error: syntax error, unexpected '$this' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST) in ""website""\admin\controller\catalog\product.php on line 7.
do you test it?

Somewhere have error code

Please help me. I m not programmer.
Last edited by Geodas81 on Tue Jun 09, 2020 4:27 am, edited 2 times in total.

Newbie

Posts

Joined
Fri Nov 08, 2019 8:26 pm

Post by straightlight » Mon Feb 17, 2020 10:40 pm

What is the code on line 7 of that file? More information is needed.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Geodas81 » Tue Feb 18, 2020 1:20 am

Forget it.At last it works.

When i try to change the product-form.twig manual before your help i made changes to the line:

Code: Select all

<h3 class="panel-title"><i class="fa fa-pencil"></i> {{ text_form }}</h3>
The result was the extension not to find right the line & don't do change to this line.

Thank you for the solution.
You are best.

Newbie

Posts

Joined
Fri Nov 08, 2019 8:26 pm
Who is online

Users browsing this forum: No registered users and 6 guests