Page 1 of 1

[SOLVED] - Showing Product Title in Admin During Product Editing

Posted: Fri Jul 08, 2011 7:26 pm
by hotwebideas
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

Re: Showing Product Title in Admin During Product Editing

Posted: Sun Feb 16, 2020 6:52 pm
by Geodas81
I know that the topic is 9 years old but is there a same solution for opencart 3.0.3.2???

Re: Showing Product Title in Admin During Product Editing

Posted: Sun Feb 16, 2020 9:54 pm
by straightlight
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.

Re: Showing Product Title in Admin During Product Editing

Posted: Mon Feb 17, 2020 12:23 am
by agatha65
For OC 3

Re: Showing Product Title in Admin During Product Editing

Posted: Mon Feb 17, 2020 1:29 am
by straightlight
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 %}

Re: Showing Product Title in Admin During Product Editing

Posted: Mon Feb 17, 2020 9:09 am
by agatha65
Oops, my bad!
I ported it from OC2.
It is fixed now.

Re: Showing Product Title in Admin During Product Editing

Posted: Mon Feb 17, 2020 3:10 pm
by Geodas81
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.

Re: Showing Product Title in Admin During Product Editing

Posted: Mon Feb 17, 2020 10:40 pm
by straightlight
What is the code on line 7 of that file? More information is needed.

Re: Showing Product Title in Admin During Product Editing

Posted: Tue Feb 18, 2020 1:20 am
by Geodas81
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.