API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Get from ProductData (Unit, Group)

0
Hi!


// Fetch list of all products
$productHandles = $client-Product_GetAll()-Product_GetAllResult-ProductHandle;
$productDataObjects =$client-Product_GetDataArray(array('entityHandles' = $productHandles))-Product_GetDataArrayResult-ProductData;

            foreach ($productDataObjects as $i = $productData) {
            
            CODE HERE

}


I can get a lot of values - like;

$productData-Number
$productData-Name
$productData-SalesPrice

But I can NOT get these values;

$productData-Unit
$productData-ProductGroup

Any ideas?

BR Thauser
created Sep 15, 2011 by thauser
0% Accept Rate
Q 3 A 7 C 0

6 Answers

0
Hi,
As you can see here - https://secure.e-conomic.com/secure/api ... ct_GetData - ProductData most certainly does include both unit and group references.

What makes you think you can't get hold of these?


BR,
answered Sep 17, 2011 by Christian Estrup
0
I can´t - try it with this code - the last two does not come out;


?

    // Helper function to check query parameters
    function checkParameter($param)
    {
        if (!$_REQUEST$param)
        {
            echo Missing code  $param  /code parameter in query string;
            exit(0);
        }       
    }
    
    checkParameter(agreementNumber);
    checkParameter(username);
    checkParameter(password);
    
    $wsdlUrl = 'https//wwwe-conomiccom/secure/api1/EconomicWebserviceasmx?WSDL';
        
    $client = new SoapClient($wsdlUrl, array(trace = 1, exceptions = 1));         
    
    echo Connecting to e-conomic APIbr /;
    $client-Connect(array(
        'agreementNumber' = $_REQUEST'agreementNumber',
        'userName'        = $_REQUEST'username',
        'password'        = $_REQUEST'password'));

try
{

    // Fetch list of all products
    $productHandles = $client-Product_GetAll()-Product_GetAllResult-ProductHandle;
    $productDataObjects =$client-Product_GetDataArray(array('entityHandles' = $productHandles))-Product_GetDataArrayResult-ProductData;

            foreach ($productDataObjects as $i = $productData) {

            echo 1 $productData-Numberbr;
            echo 2 $productData-Namebr;
            echo 3 $productData-SalesPricebr;
            echo 4 $productData-Unitbr;
            echo 5 $productData-Groupbrbr;

            }

// Disconnect e-conomic API
$client-Disconnect();
echo Disconnected from e-conomic APIbr /;
}

catch(Exception $exception)
{
    print(pi  $exception-getMessage()  /i/p);        
    $client-Disconnect();
}
?


BR Thauser
answered Sep 17, 2011 by thauser
0
I'm no expert on PHP - but what your ProductData really returns for ProductGroup and Unit are actually a ProductGroupHandle and a UnitHandle, respectively.


BR,
answered Sep 17, 2011 by Christian Estrup
0
Christian,

We are moving in the right direction - know I can get the numbers with;


$productData-UnitHandle-Number;
$productData-ProductGroupHandle-Number;


But I can NOT get the name (eg. of the unit).

In the API Contents PDF, Units is listet as including Number, Name


y.e-static.net/file-att/api-contents/api-contents.pdf

Suggestions?

BR Thauser
answered Sep 17, 2011 by thauser
0
Again, not knowing anything about PHP:

The handle 'happens to include' a Number, which 'happens to be' both the ID and the user-visible number.

However, downloading ProductData does not automatically transfer ALL properties of ALL related objects - such as unit and group. If it did, then you'd quickly be auto-recursively getting much more data than you need.

In .NET, you'd be able to do something like:

string unitName = objProductData.Unit.Name;

However, in PHP, you may or may not need to explicitly do a Unit_FindByNumber(), passing the Unit handle included in the ProductData.

Somehow I sense you SHOULD be able to do something like what you can in .NET - but suffice to say, that depends on how your PHP-WSDL-consumption-object-conversion-whatever works out, and I'm out of my league here.

Anyone?


BR,
answered Sep 18, 2011 by Christian Estrup
0
Got it - almost gave up...

Find the unit name by its number (2 in this case);


$unitHandle = array('Number' = 2);
$unitName = $client-Unit_GetName(array('unitHandle' = $unitHandle));
echo U $unitName-Unit_GetNameResultbr;


BR Thauser
answered Sep 18, 2011 by thauser
Visma e-conomic A/S
...