Post by dimitrishalkida » Tue Mar 08, 2022 2:16 am

Hello,
I want to set limit to "Additional Images" for each product in OpenCart 3.0.3.8. For example the maximum additional images per product to be 5.
It's this possible to be done with some modifications in code of OpenCart' s files? Can someone help me with that please?
Thank you in advanced!
Last edited by dimitrishalkida on Wed Mar 09, 2022 10:54 pm, edited 1 time in total.

New member

Posts

Joined
Tue Apr 07, 2015 4:18 am

Post by straightlight » Wed Mar 09, 2022 8:04 am

A VQMod file you could add.

In admin/controller/catalog/product.php file,

in the getForm() method, find:

Code: Select all

$url = '';
add above:

Code: Select all

if (isset($this->error['product_image'])) {
			$data['error_product_image'] = $this->error['product_image'];
		} else {
			$data['error_product_image'] = '';
		}
Then, in the validateForm() method, find:

Code: Select all

if ($this->request->post['product_seo_url']) {
add above:

Code: Select all

if (!empty($this->request->post['product_image']) && is_array($this->request->post['product_image']) && sizeof($this->request->post['product_image']) > 5) {
	$this->error['product_image'] = sprintf($this->language->get('error_product_image'), sizeof($this->request->post['product_image']));
}
In admin/language/en-gb/catalog/product.php file, find:

Code: Select all

$_['error_unique']
add below:

Code: Select all

$_['error_product_image'] = 'Error: You cannot upload more than 5 images. Currently %d images have been uploaded but failed!';
In admin/view/template/catalog/product_form.twig file,

add:

Code: Select all

{% if error_product_image %}
	{{ error_product_image }}
{% endif %}
where you see fit.

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 mikeinterserv » Wed Mar 09, 2022 10:21 am

I made an OCMod that does it perfectly.
It works without having to submit the form whereas the above method requires the form to be submitted.
.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by dimitrishalkida » Wed Mar 09, 2022 10:54 pm

mikeinterserv wrote:
Wed Mar 09, 2022 10:21 am
I made an OCMod that does it perfectly.
It works without having to submit the form whereas the above method requires the form to be submitted.
.
Wow!
Thank you very much, works perfect!

New member

Posts

Joined
Tue Apr 07, 2015 4:18 am
Who is online

Users browsing this forum: No registered users and 17 guests