Page 1 of 1
[SOLVED] Limit to "Additional Images" for all products to OpenCart 3.0.3.8
Posted: Tue Mar 08, 2022 2:16 am
by dimitrishalkida
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!
Re: Limit to "Additional Images" for all products to OpenCart 3.0.3.8
Posted: Wed Mar 09, 2022 8:04 am
by straightlight
A VQMod file you could add.
In admin/controller/catalog/product.php file,
in the getForm() method, find:
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:
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.
Re: Limit to "Additional Images" for all products to OpenCart 3.0.3.8
Posted: Wed Mar 09, 2022 10:21 am
by mikeinterserv
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.
.
Re: Limit to "Additional Images" for all products to OpenCart 3.0.3.8
Posted: Wed Mar 09, 2022 10:54 pm
by dimitrishalkida
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!