Jump to content

Get a variable in a php file from a function in another file


Recommended Posts

I have a php file in the root and I would like to retrieve a variable that is in a function on another php file. I need it to make a SQL query

My php file in the root    

 <?php
    require dirname(__FILE__) . '/config/config.inc.php';
    require 'modules/pricefrom/pricefrom.php';

    $lowestPrice = Db::getInstance()->getValue('
            SELECT MIN(`price`)
            FROM `' . _DB_PREFIX_ . 'product_attribute`
            WHERE `id_product` = ' . (int)$id_product
    );

I need the $id_product from another file who is required and who is in a function and use a parameters of this function

 

   <?php
    ...
    public function hookDisplayPriceBlock($param) {
            $id_product = $param['id_product'];
            $id_product_attribute = $param['id_product_attribute'];
            $product = new Product();
            ...


I know there is an easy way to make it but I'm searching for hours and I can't find, can you help me guys ?

Link to comment
Share on other sites

I would like to make it easier for you and help you, just out of curiosity, what is your final expectations? What are you trying to do at the end? Maybe I can give you an easier solution. Because the idea that you are explaining in your question seems to be no a standard way to do things in Prestashop. So if you tell me what did you plan to achieve with this code I might be able to give you another workaround.

Link to comment
Share on other sites

  • 2 weeks later...

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