Jump to content

[SOLVED]Error while overriding Product class


Recommended Posts

My product page doesn't load anymore after overriding Product class like this:

 

<?php
	Class Product extends ProductCore
	{
		public function getAdjacentPictures($product_id)
		{
	
				$sql= "SELECT id_image 
		    		FROM  `"._DB_PREFIX_."image` 
		    		WHERE  `id_product` =  $product_id";
	    		
	    		$sql_q = Db::getInstance()->getRow($sql);

	    		k = mysqli_num_rows($sql_q);
			
			for (i=1;i<k;i++
				
				{
				
				$sql2= "SELECT id_image 
		    		FROM  `"._DB_PREFIX_."image` 
		    		WHERE  `id_product` =  $product_id AND position = $i";

				$pics['$i'] = Db::getInstance()->getRow($sql2);

				}
		

		return $pics;

		}
	}
?>
Any idea? I want to get all image_id from a single product in order to let a Jquery script change them when some buttons are clicked.

 

Thank you for your help!

Edited by rofli123 (see edit history)
Link to comment
Share on other sites

Hi,

 

Turn debug on so you can see errors.

 

Why do you use getRow? isn't executeS better? I think get row will only return the first row and if you have more than 1 image to the product?

 

Do you get the the white page after you try to run the new function?

 

Did you erase class_index from cache folder?

 

1 think I will definitely do is declare $pics at the beginning because you might try to return something that is not there ( $pics = array(); )

 

Good luck

Link to comment
Share on other sites

  • 9 months later...

Hi,

I come in the discussion because I have a similar problem to add a message for some products.

 

Where do you use this function added to the product class ?

 

I have added the new field and I want to do exactly what you function do but I d'nt know where to launch the function.

 

Can you help ?

 

Jean-Marie

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...