foz1234 Posted October 25, 2016 Share Posted October 25, 2016 Is there any way to set the product image order? I have tried numbering image 1 image 2 etc but seems rather random the display order. thanks Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted October 25, 2016 Share Posted October 25, 2016 We run two CC stores. I load images from the Product Filemanager tab. I load them in the order I want them to appear, but on one store the FIRST image is the starred main image, and on the other store the LAST image chosen is the starred main image. I have absolutely no idea why they work differently, but as long as I use the appropriate sequence for each store, they both end up with a series of images in the order I want them to be. Quote Link to comment Share on other sites More sharing options...
foz1234 Posted October 25, 2016 Author Share Posted October 25, 2016 that did not seem to work for me, but i do have other images in there, i will try tomorrow to remove all images and add in order, the starred images can be changed by selecting a product then images tab select a box keep pressing empty/tick/star. Quote Link to comment Share on other sites More sharing options...
nomem Posted October 25, 2016 Share Posted October 25, 2016 This is what Brian said to do - works for me in 6.0.12 I number my images the way you do FOZ1234 In /classes/catalogue.class.php the private function _productGallery(): CODE Find about 25 lines into the function: Around Line 1747 $GLOBALS['smarty']->assign('GALLERY_JSON', json_encode($json)); return $return; Edit: $GLOBALS['smarty']->assign('GALLERY_JSON', json_encode($json)); asort($return); return $return; Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 28, 2016 Share Posted October 28, 2016 This should still work for CC610 (line 1821). Quote Link to comment Share on other sites More sharing options...
nomem Posted October 28, 2016 Share Posted October 28, 2016 Well I was just about to post that change and ask you if it would work with this upgrade. LOL Thanks Brian! Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted October 28, 2016 Share Posted October 28, 2016 Please let us know if it works for you in 6.1.0. Quote Link to comment Share on other sites More sharing options...
nomem Posted October 28, 2016 Share Posted October 28, 2016 I will! Getting ready to add a product soon Quote Link to comment Share on other sites More sharing options...
nomem Posted October 28, 2016 Share Posted October 28, 2016 I create folders for my images in filemanager. ex. clocks/vintage-united-mantle-clock. I had this product listed but decided to delete the images, clear cache, and create new image folder with a different name. I then control/clicked all 8 images from my computer for this product at once and dropped and dragged them. Then went to the product and selected the images (as before) and saved. Glad to report the edit from 6.0.12 works and my images were in the order I wanted. Nice to be able to do all 8 at once. It was a little confusing there was no save button after drop and drag though the images were checked. Wasn't sure it had worked until i went to the parent directory. So if you number your images 01-???-front 02-???-side 03-???-top etc in the order you want them to appear you will be fine. Just a note - it's important to put the 0 in front of your number in case you have over 10 images for a product. Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted October 28, 2016 Share Posted October 28, 2016 So the numbering goes in the front of the image name? My photo edit software currently names series with the numerals at the end before the .jpg. I'll have to see if I can change that for future use with this tweak. Quote Link to comment Share on other sites More sharing options...
nomem Posted October 28, 2016 Share Posted October 28, 2016 I use Photoshop. I don't save them in photoshop though. I "Save for the Web" to my computer in an individual file I've setup for each product. This file includes the images, and since I move items between my store, Etsy and eBay I created a form that keeps track of where the item is listed, if it sold and where and how much. This is handy if I get more or similar products. It also has the html code and plain text for Etsy for easy copy/paste into these venues. The form has a lot more neat stuff too. Boy I rambled didn't I! LOL. Anyway when I want to delete the image from photoshop and it asks if I want to save it I say no since I have it on my computer where I can rename it whatever I want. Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 28, 2016 Share Posted October 28, 2016 Actually, after more experimentation, I conclude the asort($return) edit will not sort on the filename as hoped. Instead, it (unreasonably) sorts on the value of the first element in the second-tier array. $result is an array of arrays. The sort function works on the first-tier values of the array. For $result, the first tier is another array. What could a sort work on if the expected argument is not something that can be sorted (like, a number or a word). For reasons unknown (and probably not reliably), the sort then grabs the value of the first element of the second tier array from each element in the main first tier array. That value happens to be the "id" of the row returned from the query against the CubeCart_image_index table. Therefore, regardless of the actual order of rows returned by the database, the sort results in the order that CubeCart gave the list of records to be databased. (The table row "id" is auto-incremented.) So, if the resulting gallery happens to be sorted by filename, it is completely coincidental and not intentional. There is a hook we can use at this very spot in the code. I will have a better solution to getting the gallery sorted by filename shortly. Quote Link to comment Share on other sites More sharing options...
nomem Posted October 28, 2016 Share Posted October 28, 2016 Thanks for delving further into this Brian. Quote Link to comment Share on other sites More sharing options...
nomem Posted October 29, 2016 Share Posted October 29, 2016 Any update on this Brian? Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 29, 2016 Share Posted October 29, 2016 In admin, Manage Hooks, Code Snippets tab, click Add Snippet. Enabled: Checked Unique ID: sort_gallery@cubecart Execution Order: 99 Description: Sorts the Product's Image Gallery by Image Filename Trigger: class.cubecart.gallery Version: 1.0 Author: forums.cubecart.com product image order PHP Code: <?php $return_filenames = array_map(function($element){return $element['filename'];},$return); array_multisort($return_filenames,$return); ?> Save. What I have available to test this myself is already sorted by filename. So, make a few tests for yourselves and see what happens. Specifically, look for instances where, when the page is first displayed, the "main" (starred) image is shown initially, but the gallery is sorted by filename. Quote Link to comment Share on other sites More sharing options...
nomem Posted October 30, 2016 Share Posted October 30, 2016 Ok it did as you said. Starred image is shown initially but the gallery is sorted by filename. Should I change the code /classes/catalogue.class.php the private function _productGallery(): back to what it is originally? See above post Thanks Brian Quote Link to comment Share on other sites More sharing options...
bsmither Posted October 30, 2016 Share Posted October 30, 2016 Yes, I recommend doing that. Quote Link to comment Share on other sites More sharing options...
nomem Posted October 30, 2016 Share Posted October 30, 2016 Code deleted, back to original - Thanks Brian Quote Link to comment Share on other sites More sharing options...
Dirty Butter Posted October 30, 2016 Share Posted October 30, 2016 Resolved? Quote Link to comment Share on other sites More sharing options...
nomem Posted October 30, 2016 Share Posted October 30, 2016 I would say so!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.