Paul Owen Posted January 27, 2014 Share Posted January 27, 2014 Hi In previous version of cubecart I found and altered the SQL query to display only featured products that had images, where is that query code in version 5 please. thanks Paul Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 27, 2014 Share Posted January 27, 2014 In the file /classes/gui.class.php, near line 933 starts a series of nine commented-out statements. Try uncommenting the last eight statements. Quote Link to comment Share on other sites More sharing options...
Paul Owen Posted January 27, 2014 Author Share Posted January 27, 2014 OK, found that which kind of works, shame some of the products have an image that says 'no image available' Is it possible to add to that code to stop it picking from certain categories? Is there a function that will return category id then I could use that I think to stop it picking featured products from certain categories? Quote Link to comment Share on other sites More sharing options...
bsmither Posted January 27, 2014 Share Posted January 27, 2014 From the statements that you uncommented, this statement: if($image && !strpos($image,"noimage")) { is supposed to do the trick. But I now see that this sequence of statements was commented out because it works on the premise that several products could be returned from the query -- only one randomly chosen product is returned from the query. So, re-comment those lines. The two statements following that group of commented statements do the same thing, but has no test for an image. Let's add it. $image = $this->getProductImage($random_product[0]['product_id']); if(strpos($image,"noimage") !== false) { if ($p < 15) { $p++; $this->_displayRandomProduct($p); } // After 15 tries, it will give up } $product = $random_product[0]; // Important to have this statement here. The thing about recursion into a function, each entry into the function creates a new set of variables used by the function. So, when exiting the function, the prior values of the function are restored. That plays havoc on keeping important values as you regress. So, one more statement to add after the top line: private function _displayRandomProduct($p=0) { static $random_product = null; static $image = null; "Can CubeCart limit the random selection from arbitrarily selected categories?" No, not as coded. 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.