Fetch and display products from a SOAP call I'm relatively new to php and any advice is appreciated. 

I retrieve some data from an external source and process them in a foreach loop to display the items. Now I'm not sure if the way I choose is the right way or if there is a better way for a situation like this. 

And here the code I use:

define ("WSDL_SERVER",
"XXX");
$oSmartFeed= new SoapClient(WSDL_SERVER);
$oSessionHash= $oSmartFeed-&gt;login('XXX', 'XXX');
if(!$oSessionHash-&gt;HasError){
$sSessionHash= $oSessionHash-&gt;Records['sessionHash'];
$aConfig= array('limit'=&gt;5, 'offset'=&gt;2, 'feeds'=&gt;[XXX]);
$aResult= $oSmartFeed-&gt; getProductData ($sSessionHash, $aConfig);

echo '&lt;ul&gt;';

foreach ($aResult-&gt;Records AS $aRecord) {

    $produktName = $aRecord['productname'];
    $imageUrl = $aRecord['imagebigurl'];
    $price = $aRecord['currentprice'] . $aRecord['currency'];
    $affLink = $aRecord['deeplinkurl'];
    $productDescription = $aRecord['productdescriptionlong'];
    $versandKosten = $aRecord['shipping'] . ' €';

    ?&gt;
       &lt;li&gt;
           &lt;a href="&lt;?php echo $affLink;?&gt;"&gt;
               &lt;img src="&lt;?php echo $imageUrl; ?&gt;" alt="&lt;?php echo $produktName; ?&gt;"&gt;
               &lt;h3&gt;
                   &lt;?php echo $produktName; ?&gt;
               &lt;/h3&gt;
               &lt;p&gt;
                   &lt;?php echo $productDescription;?&gt;
               &lt;/p&gt;
               &lt;aside&gt;
                   &lt;span&gt;
                       Price: &lt;?php echo $price; ?&gt;
                   &lt;/span&gt;
                   &lt;br&gt;
                   &lt;span&gt;
                       Shipping: &lt;?php echo $versandKosten; ?&gt;
                   &lt;/span&gt;
               &lt;/aside&gt;
           &lt;/a&gt;
       &lt;/li&gt;
    &lt;?php
}
echo '&lt;/ul&gt;';
$oSmartFeed-&gt;logout($sSessionHash);
Have you considered using a template engine vs. writing old-style PHP spaghetti code?




if(!$oSessionHash-&gt;HasError){



Reverse this conditional to get rid of the huge section of code within this conditional (whihc is actually not even closed with the code shown.  So something like:

if($oSessionHash-&gt;HasError) {
    // die, exit, redirect or similar
}
// rest of code, now no longer in a conditional.


This strategy of existing early from scripts/function/methods will help you write much less fragile code.



A number of stylistic concerns:


Drop the whole $o*, $a*, $s* variable naming (which looks like you are trying to infer variable type in name).  Your variables should have meaningful and specific names which convey their meaning. Also, if you use a good IDE, you won't need this.
Your spacing around assgniment operators, flow control structures, etc. is wildly inconsisten, making your code hard to read.  If you are strating in PHP, I would recommend getting to know the PSR-1 and PSR-2 coding standards as well as other PSR recommendations which are most widely accetped ways of writing code in the profession PHP development community. A good IDE will be able to help you enforce these styles.
Don't split your define across two lines unnecessarily like you are.




Why not perform logout immediately after your API call response is returned, rather than wait until after displaying results?



This code is very happy path oriented.  What happens if API doesn't respond? What if it responds with an error code? What if it returns empty result set?