Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7187117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:46:31+00:00 2026-05-28T18:46:31+00:00

i have a presta module in php4. It works by connecting to the database

  • 0

i have a presta module in php4. It works by connecting to the database of a prestashop and prints out xml. Whiles trying to upload to their apps store, they asked i make it php5 and follow certain proceedures.

  • In a nutshell, its just a full structural code with 1 method that gets connection to a prestashop database and prints out xml.

So the problem is how to get it to conform to the php5 standard required by prestashop. When i tried, i get this error. “class Module cannot be found”

<?php
include('config/settings.inc.php');
$con = mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
mysql_select_db(_DB_NAME_);
$str = '_DB_PREFIX_';
$str1 = constant($str);
$sql = 'SELECT '.
$str1.'product_lang.name,'.
$str1.'product.id_product as id,'.
$str1.'product.quantity,'.
$str1.'product.price,'.
$str1.'product.weight,'.
$str1.'product_lang.description,'.
$str1.'product_lang.link_rewrite as url,'.
$str1.'category_lang.name as category,'.
$str1.'manufacturer.name as manufacturer,'.
$str1.'image.id_image '.

'FROM '.
$str1.'product_lang '.
'INNER JOIN ' .$str1.'product '.
'ON ('.$str1.'product_lang.id_product = '.$str1.'product.id_product) '.
'INNER JOIN ' .$str1.'image '.
'ON ('.$str1.'image.id_product = '.$str1.'product.id_product) '.
'INNER JOIN ' .$str1.'manufacturer '.
'ON ('.$str1.'manufacturer.id_manufacturer = '.$str1.'product.id_manufacturer) '.
'INNER JOIN ' .$str1.'category_lang '.
'ON ('.$str1.'category_lang.id_category = '.$str1.'product.id_category_default) '.
//'WHERE '.$str1.'product_lang.id_lang = 1 AND '.$str1.'category_lang.id_lang = 1';
    'WHERE '.$str1.'product_lang.id_lang = 1';
    $result = mysql_query($sql);

     header("Content-Type: text/xml; charset=ISO-8859-1");
     $output = '<?xml version="1.0" encoding="utf-8"?>
     <products>';
     while($row = mysql_fetch_assoc($result)):
     //echo "<br><br><b>text:</b>".$text = addslashes($text);
     $text = str_replace(chr(145), "\'", $text);
 $output .= '
<product>
    <id>'. $row['id'].'</id>
    <name><![CDATA['.$name.']]></name>
    <description><![CDATA['.$text.']]></description>
            <image><![CDATA['. 'http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'img/p/'.$row['id'].'-'.$row['id_image'].'.jpg' .']]></image>
        <quantity><![CDATA['. $row['quantity'] .']]></quantity> 
        <price><![CDATA['. $row['price'] .']]></price>
        <weight>'. $row['weight'] .'</weight>
    <category><![CDATA['.$category.']]></category>
    <manufacturer><![CDATA['. $manufacturer.']]></manufacturer>
            <url><![CDATA['.'http://'.$_SERVER['HTTP_HOST'].'/product.php?id_product='.$row['id'].']]></url>

     </product>';
 endwhile;

 print $output .= '
 </products>';

This is the proceedure of coding i need to follow from prestashop

<?php
       //Your class must have the same name than this file.

      class module_name extends Module
       {
      public function __construct()
       {

    //Name of your module. It must have the same name than the class
    $this->name = 'module_name';

    //You must choose an existing tab amongst the ones that are available
    $this->tab = 'You choose';

    //The version of your module. Do not forget to increment the version for each modification
    $this->version = '1.0';

    //The constructor must be called after the name has been set, but before you try to use any functions like $this->l()
    parent::__construct();

    //Name displayed in the module list
    $this->displayName = $this->l('Display Name on Back Office');

    //Short description displayed in the module list
    $this->description = $this->l('Description On Back Office');    
}

//You must implement the following methods if your module need to create a table, add configuration variables, or hook itself somewhere.
//-------------------------------
public function install()
{
    return parent::install();
}

public function uninstall()
{
    return parent::install();
}
//-------------------------------

//Display Configuration page of your module.
public function getContent()
{
    return 'Hello World!';
}

   }

 ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:46:32+00:00Added an answer on May 28, 2026 at 6:46 pm

    I wrote a series of articles on writing modules for prestashop some time ago that you may find helpful: Writing your own Prestashop Module Part 1

    These describe the basic architecture and how modules are typically implemented.

    I get the feeling though that you wish this script to be standalone rather than the xml generated from within the Backoffice admin screens? If that is the case then this wouldn’t be classed as a “Module” by the Prestashop definition, and that would be the reason it has been rejected.

    Regardless of whether you’re writing a stand-alone script or a module, you also need to use the various Prestashop API calls to retrieve the product information rather than merely executing sql on the raw database tables. The reason for this is that the raw sql will not take into account factors such as language, tax or currency conversion.

    An example of how to fetch all the products and print the details about them from within a Prestashop module would be:

    global $cookie;
    
    $products = Product::getProducts($cookie->id_lang, 0, NULL,'id_product', 'ASC');
    foreach ($products AS product) {
      echo 'title: '. $product['name'];
      echo 'weight: '. $product['weight'];
      // .. etc. 
    }
    

    All the best with your Prestashop programming!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database and a Java Program. I am trying to write a
Have a string: myString = '<p>Phone Number:</p><p>706-878-8888</p>' Trying to regex out all HTML tags,
Have a n-tire web application and search often times out after 30 secs. How
Have searched the database but need to specifically sum(of hours flown or days off)in
I have written a code to delete a record in a MySQL database from
Have a xml string, goal is to replace an xml element value to a
Have some dates in my local Oracle 11g database that are in this format:
Have their been any studies related to the importance of how good a software
Have you any idea how to find out if spell check suggestions dialog is
Have a fun issue with sharepoint calendar view filtering. That code works fine: SPSecurity.RunWithElevatedPrivileges(delegate()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.