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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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