Post by vaguemind » Wed Jul 27, 2016 7:13 pm

Hello Guys,

I am using the latest version of opencart 2.2.0.0 .. and i need to make the model no. in product form in admin not mandatory and if this field is empty dont have a value , so to hide the model no. in product page on frontend .. how to do that please ?

can someone help me ?

Thanks

New member

Posts

Joined
Wed Jul 27, 2016 7:03 pm

Post by cyclops12 » Wed Jul 27, 2016 10:09 pm

First in admin/view/template/catalog/product_form.tpl find around line 98-105

Code: Select all

<div class="form-group required">
                <label class="col-sm-2 control-label" for="input-model"><?php echo $entry_model; ?></label>
                <div class="col-sm-10">
                  <input type="text" name="model" value="<?php echo $model; ?>" placeholder="<?php echo $entry_model; ?>" id="input-model" class="form-control" />
                  <?php if ($error_model) { ?>
                  <div class="text-danger"><?php echo $error_model; ?></div>
                  <?php } ?>
                </div>
And just change to

Code: Select all

<div class="form-group ">
                <label class="col-sm-2 control-label" for="input-model"><?php echo $entry_model; ?></label>
                <div class="col-sm-10">
                  <input type="text" name="model" value="<?php echo $model; ?>" placeholder="<?php echo $entry_model; ?>" id="input-model" class="form-control" />
                  <?php if ($error_model) { ?>
                  <div class="text-danger"><?php echo $error_model; ?></div>
                  <?php } ?>
                </div>
Then in catalog/view/theme/YOUR_THEME/template/product/product.tpl and find around line 131

Code: Select all

<?php echo $text_model; ?> <?php echo $model; ?>
And comment it out like this

Code: Select all

<!-- <li><?php echo $text_model; ?> <?php echo $model; ?></li> -->

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by vaguemind » Thu Jul 28, 2016 3:29 pm

thanks cyclops12

but is this always hide the model no from the product page ? I need it to be shown if has a value only but if empty dont shown on product page ?

Thanks

New member

Posts

Joined
Wed Jul 27, 2016 7:03 pm

Post by cyclops12 » Thu Jul 28, 2016 10:37 pm

Ah ok

Try this then,
First in admin/view/template/catalog/product_form.tpl find around line 98-105

Code: Select all

<div class="form-group required">
                <label class="col-sm-2 control-label" for="input-model"><?php echo $entry_model; ?></label>
                <div class="col-sm-10">
                  <input type="text" name="model" value="<?php echo $model; ?>" placeholder="<?php echo $entry_model; ?>" id="input-model" class="form-control" />
                  <?php if ($error_model) { ?>
                  <div class="text-danger"><?php echo $error_model; ?></div>
                  <?php } ?>
                </div>

And just change to

Code: Select all

<div class="form-group ">
                <label class="col-sm-2 control-label" for="input-model"><?php echo $entry_model; ?></label>
                <div class="col-sm-10">
                  <input type="text" name="model" value="<?php echo $model; ?>" placeholder="<?php echo $entry_model; ?>" id="input-model" class="form-control" />
                  <?php if ($error_model) { ?>
                  <div class="text-danger"><?php echo $error_model; ?></div>
                  <?php } ?>
                </div>
Then in admin/controller/catalog/product.php around line 1318 find

Code: Select all

if ((utf8_strlen($this->request->post['model']) < 1) || (utf8_strlen($this->request->post['model']) > 64)) {
			$this->error['model'] = $this->language->get('error_model');
		}
And change to

Code: Select all

if ((utf8_strlen($this->request->post['model']) > 64)) {
			$this->error['model'] = $this->language->get('error_model'); 
		}
Then in catalog/view/theme/YOUR_THEME/template/product/product.tpl around line 132 find

Code: Select all

<li><?php echo $text_model; ?> <?php echo $model; ?></li>
And change to

Code: Select all

<?php if ($model) { ?>
            <li><?php echo $text_model; ?> <?php echo $model; ?></li>
			<?php } ?>
Hopefully this will help you out

And anyone wiser than me then please feel free to let me know if this is wrong !!

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by vaguemind » Fri Jul 29, 2016 1:08 am

Thank you for your help, actually i tried this out , the model no in admin remained mandatory .. but then i used an extension that make model no not mandatory .. and i modified in catalog/view/theme/YOUR_THEME/template/product/product.tpl .. so it became hidden from frontend .. so its ok now.

if i need to add a "Vendor code" field also in product form .. i make the same way ? right ?

New member

Posts

Joined
Wed Jul 27, 2016 7:03 pm

Post by cyclops12 » Fri Jul 29, 2016 4:03 am

I would think to looking at adding an extension for custom fields

Maybe one of these will help

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by vaguemind » Sun Jul 31, 2016 4:17 pm

i cant find a good free extension to do that ?

New member

Posts

Joined
Wed Jul 27, 2016 7:03 pm

Post by cyclops12 » Sun Jul 31, 2016 5:54 pm

This may give you a few clues, but this is only up to version 2.1

If you goto the relevant files and compare the data you should be able to work out how to get this working

Always make a backup FIRST though, just in case

EDIT: have made an ocmod to test on oc2.2 and works good

Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by straightlight » Mon Aug 01, 2016 1:29 am

Take note from the link above that the following parts of instructions on that site where it indicates:
after adding the above code, the complete insert query will be like this:
and
after adding the above code, the complete update query will be like this:
might be subject to change upon Opencart releases since these instructions describe results on a block of code that may have been modified afterwards.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

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

Post by vaguemind » Mon Aug 01, 2016 2:17 am

ya , i followed exactly the steps but i face error on admin :

Notice: Undefined index: entry_newfield1 in /home/fekman/public_html/test/vqmod/vqcache/vq2-system_storage_modification_admin_model_catalog_product.php on line 136

and also on frontend doesnt show the field ?

New member

Posts

Joined
Wed Jul 27, 2016 7:03 pm

Post by straightlight » Mon Aug 01, 2016 3:27 am

vaguemind wrote:ya , i followed exactly the steps but i face error on admin :

Notice: Undefined index: entry_newfield1 in /home/fekman/public_html/test/vqmod/vqcache/vq2-system_storage_modification_admin_model_catalog_product.php on line 136

and also on frontend doesnt show the field ?
Followed is the FAQ topic regarding VQ2 Cache errors: http://forum.opencart.com/viewtopic.php?f=170&t=165657

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

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

Post by cyclops12 » Mon Aug 01, 2016 3:36 am

vaguemind wrote:ya , i followed exactly the steps but i face error on admin :

Notice: Undefined index: entry_newfield1 in /home/fekman/public_html/test/vqmod/vqcache/vq2-system_storage_modification_admin_model_catalog_product.php on line 136

and also on frontend doesnt show the field ?
Did you make sure you run the sql query to start with
level1.JPG

level1.JPG (40.75 KiB) Viewed 1712 times

And to display in front end you have to follow link at bottom
display-front.JPG

display-front.JPG (32.57 KiB) Viewed 1712 times


Expert Member

Posts

Joined
Sun Sep 27, 2015 1:10 am

Post by straightlight » Mon Aug 01, 2016 3:38 am

The table prefix name: oc_ may have to be renamed if a different prefix name is involved. Otherwise, the query will fail to add the field to the proper target database table.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer / Opencart Tester


Legendary Member

Posts

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

Post by vaguemind » Mon Aug 01, 2016 5:04 am

ya , thanks a lot .. it was error from db query , i fixed it and it worked well

New member

Posts

Joined
Wed Jul 27, 2016 7:03 pm
Who is online

Users browsing this forum: No registered users and 6 guests