NixxxoN Posted January 25, 2021 Share Posted January 25, 2021 Hi! We're building a big shop, around 700.000 products, and some of them have photos/images and some dont. I wonder if it's possible to sort products in the product list in this way. Separate products that have image/photo from the others that don't, and then show first the ones that do have images/photos. Any idea?? Thanks! Link to comment Share on other sites More sharing options...
Constantino Posted January 25, 2021 Share Posted January 25, 2021 Hello, may I know the purpose of such ordering? Link to comment Share on other sites More sharing options...
NixxxoN Posted January 25, 2021 Author Share Posted January 25, 2021 3 minutes ago, Constantino said: Hello, may I know the purpose of such ordering? It's about aestethics, a product list with many of them having no photo doesnt look very good, so the purpose is to try to "hide" them a bit Link to comment Share on other sites More sharing options...
Constantino Posted January 26, 2021 Share Posted January 26, 2021 hmmm...I can recommend using a third-party tool - Store Manager for PrestaShop (there's a trial version available), with it you can: 1) find products without images with Store Diagnostics (you'll have the list of products with the possibility to export them) 2) change product position via export/import having 2 columns in the file: product ID and position * you can also add images to products right from the diagnostics window Link to comment Share on other sites More sharing options...
NixxxoN Posted January 26, 2021 Author Share Posted January 26, 2021 17 minutes ago, Constantino said: hmmm...I can recommend using a third-party tool - Store Manager for PrestaShop (there's a trial version available), with it you can: 1) find products without images with Store Diagnostics (you'll have the list of products with the possibility to export them) 2) change product position via export/import having 2 columns in the file: product ID and position * you can also add images to products right from the diagnostics window We bought this already! But it gives us error 504 gateway timeout when trying to get all the data from the server! Its about 700.000 products, takes so long...! How can we solve this? Link to comment Share on other sites More sharing options...
musicmaster Posted January 26, 2021 Share Posted January 26, 2021 (edited) With so many products I would just customize the queries that Prestashop uses. It is also the more logical approach. You don't want sort products again each time you a few new ones. Edited January 26, 2021 by musicmaster (see edit history) Link to comment Share on other sites More sharing options...
NixxxoN Posted January 26, 2021 Author Share Posted January 26, 2021 56 minutes ago, musicmaster said: With so many products I would just customize the queries that Prestashop uses. It is also the more logical approach. You don't want sort products again each time you a few new ones. Yes, I suppose this is the logical way. But how would you query to show products with no images to appear last?? Link to comment Share on other sites More sharing options...
musicmaster Posted January 26, 2021 Share Posted January 26, 2021 1 hour ago, NixxxoN said: Yes, I suppose this is the logical way. But how would you query to show products with no images to appear last?? Basically: when a product has an image it has a presence in the ps_image table. When not, then not. I don't remember at the moment the best way to put it into a query. But you could always ask on some SQL forum. 1 Link to comment Share on other sites More sharing options...
Constantino Posted January 27, 2021 Share Posted January 27, 2021 17 hours ago, NixxxoN said: But it gives us error 504 gateway timeout when trying to get all the data from the server! Its about 700.000 products, takes so long...! How can we solve this? Did you contact eMagicOne for assistance with this? Link to comment Share on other sites More sharing options...
NixxxoN Posted January 27, 2021 Author Share Posted January 27, 2021 4 hours ago, Constantino said: Did you contact eMagicOne for assistance with this? Thats what I just did, hope they will help. I suppose they have experience with very large shops Link to comment Share on other sites More sharing options...
Constantino Posted January 27, 2021 Share Posted January 27, 2021 3 hours ago, NixxxoN said: I suppose they have experience with very large shops yes, the software does handle large shops, so I think it's just a question of some optimization settings Link to comment Share on other sites More sharing options...
Zudjo Posted October 28, 2023 Share Posted October 28, 2023 (edited) I resolved this with with a little override of classes/controller/ProductListingFrontController.php inside the method getProductSearchVariables() // EDIT: THIS CODE DOESN'T WORK AS INTENDED // IT REMOVES FROM THE PRODUCTS OF THE PAGE // ALL PRODUCTS WITHOUT IMAGE // prepare the products $products = $this->prepareMultipleProductsForTemplate( $result->getProducts() ); // --- custom code - start // order products with cover_image_id not null first $products = array_filter($products, function($product) { return $product['cover_image_id'] != null; }); // --- custom code - end EDIT: I'm updating this post to avoid anyone using this code to have problems. Mostly because is a very subtle problem where effectively you don't see anymore the products without image, but, you will never see them... Integrating this with prestashop was a little bit tricky, and to do this I ended up using the `mpn` column value as a 'product has image or not' column value. So, after cycling to every prestashop product something like this code: public function setHasImage() : void { $hasImage = Image::hasImages(1, $this->id); if ($hasImage) { $this->mpn = 1; } else { $this->mpn = 0; } } I went ahead adding one line of code in an override of classes/controller/ProductListingFrontController.php inside the method getProductSearchVariables() // set the sort order if provided in the URL if (($encodedSortOrder = Tools::getValue('order'))) { $query->setSortOrder(SortOrder::newFromString( $encodedSortOrder )); } // start custom code // mpn is used as hasImage flag $query->setSortOrder(new SortOrder('product', 'mpn', 'desc')); // end custom code Edited November 6, 2023 by Zudjo Precedent proposed solution wasn't actually resolving the problem (see edit history) Link to comment Share on other sites More sharing options...
NixxxoN Posted October 28, 2023 Author Share Posted October 28, 2023 (edited) 6 hours ago, Zudjo said: I resolved this with with a little override of classes/controller/ProductListingFrontController.php inside the method getProductSearchVariables() // prepare the products $products = $this->prepareMultipleProductsForTemplate( $result->getProducts() ); // --- custom code - start // order products with cover_image_id not null first $products = array_filter($products, function($product) { return $product['cover_image_id'] != null; }); // --- custom code - end Wow, that's a really old thread and this project is done now. I completely forgot. When I say "it's done" I mean its abandonned haha. I'll sum up the story for you - My customer wanted to do an over-ambitious project, he was willing to go alone against kinda large companies to sell books on the internet. He hired me to do a massive online shop with more than half a million products (books) with a Prestashop store, and I "kinda" eventually did it, more or less, with many pictures remaining still.... but then after a long time he realised it was an impossible task, the server requirements were very high, so a lot of money to spend on it, and too much work to do... The Prestashop system surprisingly held up, but still... So many problems for him. Thanks anyway for the reply, appreciate it! Edited October 28, 2023 by NixxxoN (see edit history) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now