Jump to content

image URL generating


elektrojo

Recommended Posts

I am trying to get image URL for prestashop product depending on it's ID 

I am trying this code for methods provided by prestashop, but I get nothing 

 

        <?php

    

    //require('config/settings.inc.php');

    //require('classes/Image.php');

    require('classes/Link.php');

    $ItemID=$_GET["catID"];

    $db=mysql_connect(constant('_DB_SERVER_'),constant('_DB_USER_'), constant

    

    

    $image = Image::getCover($ItemID);

    $imagePath = Link::getImageLink($product->link_rewrite, $image['id_image'], 'home_default');

    

    

 

 

 this code is not working I tried to include the required classes but they also produce a problem just by adding them


 //require('config/settings.inc.php');

    //require('classes/Image.php');

 

 


 also if I commented last two line the require itself produce an error 

my other working code that I am planing to build a table of images URL manually is wroking 

 

    <?php

    require('config/settings.inc.php');

    $ItemID=$_GET["catID"];

    $db=mysql_connect(constant('_DB_SERVER_'),constant('_DB_USER_'), constant

    

    ('_DB_PASSWD_')) or die('Could not connect');

    mysql_select_db(constant('_DB_USER_'), $db) or die('');

     if (is_numeric($ItemID)) {

    $result = mysql_query("SELECT name,date_add,price , IFNULL(imageURL,'') as imageURL 

    

    FROM product inner join product_lang on product_lang.id_product=product.id_product 

    

    left join app_product_image on product.id_product=app_product_image.id_product where 

    

    id_lang=1 and product.id_product='$ItemID'") or die('Could not query');

    $json = array();

        if(mysql_num_rows($result)){

               // $row=mysql_fetch_assoc($result);

            while($row=mysql_fetch_row($result)){

                //  cast results to specific data types

    

                //$test_data[]=$row;

    $json['name']=$row[0];

    $json['date']=$row[1];

    $json['price']=$row[2];

    $json['imgURL']=$row[3];

   

    }

           // $json['products']=$test_data;

        }

       echo json_encode($json);

        mysql_close($db);

    

     

     }

 

 

 

the above code is the last solution but i am trying not to write the products images URL manually!

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...