eledesmaj Posted November 2, 2012 Share Posted November 2, 2012 I'm having the following problem with a third party script image name is getting renamed to /catalog/view/theme/default/image/stars-5.0000.png instead of /catalog/view/theme/default/image/stars-5.png here is the script any help would be appreciated Thanks <modification> <id><![CDATA[AutoRelated Products]]></id> <version><![CDATA[4.0]]></version> <vqmver><![CDATA[2.4.5]]></vqmver> <author><![CDATA[sopedro]]></author> <file name="catalog/controller/product/product.php"> <operation> <search position="after"><![CDATA[$results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);]]></search> <add><![CDATA[ //related by category if(count($results)<4){//change to suit number of products to display $temp = $this->model_catalog_product->getProductRelatedByCategory($this->request->get['product_id'],count($results)); foreach($temp as $t){ if(!empty($t)){ $results[] = $t; } } } //related by manufacturer $this->data['product_info'] = $product_info; if(count($results)<4 && (int)$this->data['product_info']['manufacturer_id'] > 0){//change to suit number of products to display $temp = $this->model_catalog_product->getProductRelatedByManufacturer($this->data['product_info']['manufacturer_id'],$this->request->get['product_id'],count($results)); foreach($temp as $t){ if(!empty($t)){ $results[] = $t; } } } //related by randomisation if(count($results)<4){//change to suit number of products to display $temp = $this->model_catalog_product->getProductRelatedByNothing($this->request->get['product_id'],count($results)); foreach($temp as $t){ if(!empty($t)){ $results[] = $t; } } } ]]></add> </operation> </file> <file name="catalog/model/catalog/product.php"> <operation> <search position="after" offset="4"><![CDATA[$product_data[$result['related_id']] = $this->getProduct($result['related_id']);]]></search> <add><![CDATA[ public function getProductRelatedByCategory($product_id,$num_results) { //return array(); $product_data = array(); $num = 4 - $num_results;//change to suit number of products to display $getCat = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE product_id = '" . (int)$product_id . "'"); $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_to_category WHERE category_id = '" . (int)$getCat->row['category_id'] . "' AND product_id != '" . (int)$product_id . "' ORDER BY RAND() LIMIT 0,".$num.""); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductRelatedByManufacturer($manufacturer_id,$product_id,$num_results) { //return array(); $product_data = array(); $num = 4 - $num_results;//change to suit number of products to display $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product WHERE manufacturer_id = '" . (int)$manufacturer_id . "' AND product_id != '" . (int)$product_id . "' LIMIT 0,".$num.""); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } public function getProductRelatedByNothing($product_id,$num_results) { $product_data = array(); $num = 4 - $num_results;//change to suit number of products to display $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product WHERE product_id != '" . (int)$product_id . "' ORDER BY RAND() LIMIT 0,".$num.""); foreach ($query->rows as $result) { $product_data[$result['product_id']] = $this->getProduct($result['product_id']); } return $product_data; } ]]></add> </operation> </file> </modification> Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 2, 2012 Share Posted November 2, 2012 When posting code, enclose it within the forum's . . . BBCode tags. Quote Link to comment Share on other sites More sharing options...
eledesmaj Posted November 2, 2012 Author Share Posted November 2, 2012 sorry about that new to the site thanks Quote Link to comment Share on other sites More sharing options...
Christian F. Posted November 2, 2012 Share Posted November 2, 2012 (edited) Find where the image name is being generated, and add intval () around the variable containing the numerical part. Reason for the problem seems to be that the numerical part is stored as a float, somewhere, and thus gives you the extra characters. To properly fix this issue, find out where this happens and whether or not it's necessary. If not, change it to store the number as an INT. Otherwise, see the first line. Edited November 2, 2012 by Christian F. 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.