Jump to content

Image Url Getting Rewritten And Not Showing Proper Image


eledesmaj

Recommended Posts

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>

Link to comment
Share on other sites

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 by Christian F.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.