Post by depechemode75 » Mon Jun 22, 2020 11:38 pm

Hi everyone, I'd like to know if there is a way to have opencart upload the product images by name without necessarily having to manually enter the values in the images section.

Example:
image-name-01 (main)
name-picture-02
name-picture-03
name-picture-04
.........

I noticed that opencart if you do not enter the values manually, upload the photos in random sequence, so I would like to know if there is a way and if someone could kindly help me set the upload by ordering by name

Thanks so much!!

New member

Posts

Joined
Sun Dec 31, 2017 12:09 am

Post by rjcalifornia » Tue Jun 23, 2020 12:45 pm

depechemode75 wrote:
Mon Jun 22, 2020 11:38 pm
Hi everyone, I'd like to know if there is a way to have opencart upload the product images by name without necessarily having to manually enter the values in the images section.

Example:
image-name-01 (main)
name-picture-02
name-picture-03
name-picture-04
.........

I noticed that opencart if you do not enter the values manually, upload the photos in random sequence, so I would like to know if there is a way and if someone could kindly help me set the upload by ordering by name

Thanks so much!!
I don't understand your issue. Is it the upload manager or the product images?

You manually add product images (one by one), and you can set the order as well (it has a field for that)

Image
A2 Hosting features: Shared Turbo Boost, Managed Warp 1, Unmanaged Hyper 1, and Warp 2 Turbo


Active Member

Posts

Joined
Fri Sep 02, 2011 1:19 pm
Location - Worldwide

Post by depechemode75 » Tue Jun 23, 2020 4:33 pm

the problem is in the sequence of additional images on the product page. I create a new product and load for example 6 images, I want the sequence of images loaded when scrolling the carousel to be displayed sorted by name in ascending order, I believe that opencart displays the images starting from the last image loaded before ending with the first or in random order.

To do this I would have to set the values ​​"0 1 2 ......) to order them but when you have 2000 products it is impossible to do this.

Loading sorting system defalt:
image-01 (main image)
image-04
image-03
image-02.......

I would like it to be automatically set as follows:
image-01 (main image)
image-02
image-03
image-04........

without having to manually set the values.

New member

Posts

Joined
Sun Dec 31, 2017 12:09 am

Post by sw!tch » Tue Jun 23, 2020 4:55 pm

You need this on just the slider? You can easily do this from the select statement and adjust the order by.

Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by letxobnav » Tue Jun 23, 2020 5:03 pm

there is a difference between product main image, product additional images and banner images, so which sequence are you talking about?

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by depechemode75 » Tue Jun 23, 2020 5:25 pm

I understand this but I can't do it x 2000 individually produced, I would like if possible to have opencart automatically put them in order by increasing name, independent if I load them one by one or in bulk

New member

Posts

Joined
Sun Dec 31, 2017 12:09 am

Post by depechemode75 » Tue Jun 23, 2020 5:27 pm

letxobnav wrote:
Tue Jun 23, 2020 5:03 pm
there is a difference between product main image, product additional images and banner images, so which sequence are you talking about?
talk about additional product images

New member

Posts

Joined
Sun Dec 31, 2017 12:09 am

Post by letxobnav » Tue Jun 23, 2020 5:42 pm

I want the sequence of images loaded when scrolling the carousel to be displayed sorted by name in ascending order
what have the additional product images to do with a carousel?

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by depechemode75 » Tue Jun 23, 2020 5:51 pm

letxobnav wrote:
Tue Jun 23, 2020 5:42 pm
I want the sequence of images loaded when scrolling the carousel to be displayed sorted by name in ascending order
what have the additional product images to do with a carousel?
the carousel of the product page to scroll through the images .... I use journal3

New member

Posts

Joined
Sun Dec 31, 2017 12:09 am

Post by letxobnav » Tue Jun 23, 2020 6:28 pm

not sure how journal does it but you could try

catalog/model/catalog/product.php
change:

Code: Select all

	public function getProductImages($product_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC");

		return $query->rows;
	}

to:

Code: Select all

	public function getProductImages($product_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC, image ASC");

		return $query->rows;
	}

that sorts the additional images on sort order first and then on the filename.
The main image is in a separate query though as it resides in the product table.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by depechemode75 » Tue Jun 23, 2020 6:34 pm

letxobnav wrote:
Tue Jun 23, 2020 6:28 pm
not sure how journal does it but you could try

catalog/model/catalog/product.php
change:

Code: Select all

	public function getProductImages($product_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC");

		return $query->rows;
	}

to:

Code: Select all

	public function getProductImages($product_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC, image ASC");

		return $query->rows;
	}

that sorts the additional images on sort order first and then on the filename.
The main image is in a separate query though as it resides in the product table.
today I will try and let you know if it works. Meanwhile, thank you

New member

Posts

Joined
Sun Dec 31, 2017 12:09 am

Post by depechemode75 » Wed Jun 24, 2020 2:36 am

depechemode75 wrote:
Tue Jun 23, 2020 6:34 pm
letxobnav wrote:
Tue Jun 23, 2020 6:28 pm
not sure how journal does it but you could try

catalog/model/catalog/product.php
change:

Code: Select all

	public function getProductImages($product_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC");

		return $query->rows;
	}

to:

Code: Select all

	public function getProductImages($product_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_image WHERE product_id = '" . (int)$product_id . "' ORDER BY sort_order ASC, image ASC");

		return $query->rows;
	}

that sorts the additional images on sort order first and then on the filename.
The main image is in a separate query though as it resides in the product table.
today I will try and let you know if it works. Meanwhile, thank you

It works perfectly, now the additional images are sorted by name in ascending order without the need to enter any values manually.
Oc 3.0.3.3
Journal Theme 3
Thanks for your help!!

New member

Posts

Joined
Sun Dec 31, 2017 12:09 am

Post by Cue4cheap » Thu Jun 25, 2020 9:56 am

letxobnav wrote:
Tue Jun 23, 2020 6:28 pm
that sorts the additional images on sort order first and then on the filename.
The main image is in a separate query though as it resides in the product table.
Brilliant letxobnav!! Using that AND this: https://www.opencart.com/index.php?rout ... n_id=22772

Makes it so it is pretty easy to have options sorted and images sorted to correlate with each other.

Thank you,
Mike

cue4cheap not cheap quality


Expert Member

Posts

Joined
Fri Sep 20, 2013 4:45 am

Post by letxobnav » Thu Jun 25, 2020 11:45 am

I always do it that way, set the main sort order to a specific field and use the sort_order field just to force certain records to the top or bottom or leave all sort_order fields the same so it is ignored.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan
Who is online

Users browsing this forum: No registered users and 11 guests