Jump to content

Google base RSS php problem


eog

Recommended Posts

Hi

 

Hopefully someone can help me. My knowledge of PHP doesnt go any further than looking at identifying areas of code and copy and paste - as basic as you get!

 

Basically i have a php script installed that produces an RSS feed for me to use with google base. There is a little problem were it does not pull the sale price(known as special)  into googlebase and it will instead show the original price. I have identified what needs to be changed but i dont know the correct syntax.

 

 

I somehow need to get something similar to the following IF ELSE into the code below (this is taken from the same php script that shows the special price on the actual rss feed)

 

foreach ($product_data as $result) {

$special = $model_catalog_product->getProductSpecial($result['product_id']);

if ($special) {

$price = $special;

} else {

$price = $result['price'];

}

if ($useTax) {

$price = $currency->format($tax->calculate($price, $result['tax_class_id'], $config->get('config_tax')), $currency->getCode());

} else {

$price = $currency->format($price, $currency->getCode());

}

 

 

The code below is were i need the If Else inserted.

 

 

<?php foreach ($products as $product) { ?>

<item>

        <title><?php echo htmlspecialchars($product['name'], ENT_QUOTES, 'utf-8'); ?></title>

        <g:brand><?php echo htmlspecialchars($product['brand'], ENT_QUOTES, 'utf-8'); ?></g:brand>

<g:condition>new</g:condition>

<g:product_type><?php echo $taxonomy; ?></g:product_type>

        <description><?php echo htmlspecialchars($product['desc'], ENT_QUOTES, 'utf-8'); ?></description>

        <link><?php echo str_replace('&', '&', $product['href']); ?></link>

        <pubDate><?php echo $product['add_date']; ?></pubDate>

        <!--guid isPermaLink="true"><?php echo $product['href']; ?></guid-->

        <g:id><?php echo (int)$product['id']; ?></g:id>

<!--g:upc><?php echo sprintf("%012s", $product['id']); ?></g:upc-->

        <g:image_link><?php echo $product['thumb']; ?></g:image_link>

<!--g:expiration_date>2010-01-01</g:expiration_date-->

<g:price><?php echo $product['price']; ?></g:price>

<g:mpn><?php echo htmlspecialchars($product['model'], ENT_QUOTES, 'utf-8'); ?></g:mpn>

<g:weight><?php echo $product['weight']; ?></g:weight>

<g:currency><?php echo $config->get('config_currency'); ?></g:currency>

</item>

<?php } ?>

 

 

The <g:price> is what googlebase reads to get the price of the product. The problem seems to be that there is no if else statement here to output the special price if there is one.

 

 

Any help would be greatly appreciated, i tired emailing the developer but i have been ignored and as you can see i'm pretty clueless  :'(

 

Link to comment
https://forums.phpfreaks.com/topic/220254-google-base-rss-php-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.