Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Another Google Base issue - Price vs Sales Price
 
walltoolsllc
Sr. Member
 
Total Posts:  146
Joined:  2008-08-21
 
Dr_Frankenstein - 24 January 2010 04:51 AM

Arrgg just wrote a whole post and lost it

Sorry for the late reply but I didn’t have notifications for this thread turned on

See attached for a pic of how I submit special prices to base

It will submit the normal price if you have no figures in the special price field for the product and if the special price field is populated it submits that price instead

I would also recommend using the fix in the thread below to stop it submitting special prices for the wrong products

http://www.magentocommerce.com/boards/viewthread/50999/#t189625

I have it set up just like the photo:  Special Price >>>> price

But it’s still showing my regular pricing in Google Search Results/Shopping Results?  What gives?

 
Magento Community Magento Community
Magento Community
Magento Community
 
WebSiteEvo
Jr. Member
 
Total Posts:  12
Joined:  2010-01-26
 

There must be a function to retrieve the price after price rules have been applied. Otherwise the answer is to quarry the database directly.

 
Magento Community Magento Community
Magento Community
Magento Community
 
WebSiteEvo
Jr. Member
 
Total Posts:  12
Joined:  2010-01-26
 
lukewd - 31 May 2010 02:28 AM

it does not work for products that have a special price set using promotions and price rules, unfortunately.

Make changes to: app/code/core/GoogleBase/Model/Service/Item.php to retrieve the price rule price.

$attributeValues $this->getAttributeValues();
        
        
/// work out special price using rule price here: 
            
$write Mage::getSingleton('core/resource')->getConnection('core_write');
            
$readresult=$write->query("SELECT rule_price FROM catalogrule_product_price WHERE product_id = ".$object->getId()." ORDER BY rule_product_price_id DESC LIMIT 1 ");
            
$specialprice 0;
            while (
$row $readresult->fetch() ) {
            $specialprice 
$row['rule_price'];
            


        
if (isset($attributeValues['price']['value']) && floatval($attributeValues['price']['value']) > 0{
            $price 
$attributeValues['price']['value'];
        
else {
            $price 
$_product->getId();
        
}
            
if (($specialprice 0)&&($specialprice $price)) {
            $price 
$specialprice;
            
}

        $this
->_setAttributePrice(false$price);
 
Magento Community Magento Community
Magento Community
Magento Community
 
toocan
Member
 
Total Posts:  37
Joined:  2008-01-07
 
WebSiteEvo - 12 November 2010 04:10 AM

lukewd - 31 May 2010 02:28 AM
it does not work for products that have a special price set using promotions and price rules, unfortunately.

Make changes to: app/code/core/GoogleBase/Model/Service/Item.php to retrieve the price rule price.

$attributeValues $this->getAttributeValues();
        
        
/// work out special price using rule price here: 
            
$write Mage::getSingleton('core/resource')->getConnection('core_write');
            
$readresult=$write->query("SELECT rule_price FROM catalogrule_product_price WHERE product_id = ".$object->getId()." ORDER BY rule_product_price_id DESC LIMIT 1 ");
            
$specialprice 0;
            while (
$row $readresult->fetch() ) {
            $specialprice 
$row['rule_price'];
            


        
if (isset($attributeValues['price']['value']) && floatval($attributeValues['price']['value']) > 0{
            $price 
$attributeValues['price']['value'];
        
else {
            $price 
$_product->getId();
        
}
            
if (($specialprice 0)&&($specialprice $price)) {
            $price 
$specialprice;
            
}

        $this
->_setAttributePrice(false$price);

Hi can you explain this in a bit more details please. ie to get the special price with the fallback of normal price in the feed do i have to implement just this change? OR do I also need to create some custom mapping in the magento admin

 
Magento Community Magento Community
Magento Community
Magento Community
 
WebSiteEvo
Jr. Member
 
Total Posts:  12
Joined:  2010-01-26
 

This is not yet tested.! so in theory, the code above should fall back to normal price or mapped price (however you set it up)… it should only use the discount rule price if there is one. I have not built in Special Price, but that would be easy enough to incorporate if your not using the mapped special price. This is meant as a starting point for people to develop a solution. I will post any updates if I make further changes.

 
Magento Community Magento Community
Magento Community
Magento Community
 
WebSiteEvo
Jr. Member
 
Total Posts:  12
Joined:  2010-01-26
 

Correction:  $price = $object->getPrice();

$attributeValues $this->getAttributeValues();
        
        
/// work out special price using rule price here: 
            
$write Mage::getSingleton('core/resource')->getConnection('core_write');
            
$readresult=$write->query("SELECT rule_price FROM catalogrule_product_price WHERE product_id = ".$object->getId()." ORDER BY rule_product_price_id DESC LIMIT 1 ");
            
$specialprice 0;
            while (
$row $readresult->fetch() ) {
            $specialprice 
$row['rule_price'];
            


        
if (isset($attributeValues['price']['value']) && floatval($attributeValues['price']['value']) > 0{
            $price 
$attributeValues['price']['value'];
        
else {
            $price 
$object->getPrice();
        
}
            
if (($specialprice 0)&&($specialprice $price)) {
            $price 
$specialprice;
            
}

        $this
->_setAttributePrice(false$price);
 
Magento Community Magento Community
Magento Community
Magento Community
 
Anton B
Member
 
Avatar
Total Posts:  37
Joined:  2009-01-20
 

Tried WebSiteEvo’s latest fix, still getting regular price which I use as MSRP and then use Catalog Price Rules to show discounted price.

 
Magento Community Magento Community
Magento Community
Magento Community
 
avanawill
Jr. Member
 
Total Posts:  3
Joined:  2010-11-26
New York
 

I have the same problem , I want to map the special price to the google base product but instead of displaying the special price value it show me the regular price on the google base account. I think from magento code instead of checking for the special price it direcly send the regular price to the google .

 
Magento Community Magento Community
Magento Community
Magento Community
 
mgarratt
Jr. Member
 
Total Posts:  18
Joined:  2010-04-08
 

Building further on what WebSiteEvo has done I think I have come up with a solution for this.

The first thing I did was copy app/code/core/Mage/GoogleBase/Model/Service/Item.php to app/code/local/Mage/GoogleBase/Model/Service/Item.php so that it is protected from updates.

I then changed this:

$attributeValues $this->getAttributeValues();
        
        if (isset(
$attributeValues['price']['value']) && floatval($attributeValues['price']['value']) > 0{
            $price 
$attributeValues['price']['value'];
        
else {
            $price 
$object->getPrice();
        
}

        $this
->_setAttributePrice(false$price);

To this:

$attributeValues $this->getAttributeValues();
        
        if (isset(
$attributeValues['price']['value']) && floatval($attributeValues['price']['value']) > 0{
            $price 
$attributeValues['price']['value'];
        
else {
            
// Initialise array, add standard Price
            
$min_values = array();
            
$min_values[] $object->getPrice();
            
            
// If Special Price is set, add to array
            
if($object->getSpecialPrice() > 0{ $min_values[] $object->getSpecialPrice(); }
            
            
// Get Catalog Price Rule Price
            
$write Mage::getSingleton('core/resource')->getConnection('core_write');
            
$readresult=$write->query("SELECT rule_price FROM catalogrule_product_price WHERE product_id = ".$object->getId()." ORDER BY rule_product_price_id DESC LIMIT 1 ");
            
// If a result is returned, add to array
            
while ($row $readresult->fetch() ) { $min_values[] $row['rule_price']
            
            
// Set price for GoogleBase to minimum of 3 prices
            
$price min($min_values);
        
}

        $this
->_setAttributePrice(false$price);

This starts at line 283.

I have tested with special prices and catalog price rules and it seems to be working. I am using Magento Version 1.4.1.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
hammock_vienna
Member
 
Total Posts:  60
Joined:  2008-06-16
 

Yes this sniplet works perfect. But unfortunatly the synchronisation process doesnt work. If you change the value of an attribute and then press sync the new values are not in sync with GB. I have read in another thread that this whole GB implementation isnt finished.

Be aware: if you have net prices in your shop - you\’ll push net prices to GB.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Anton B
Member
 
Avatar
Total Posts:  37
Joined:  2009-01-20
 

What are you guys doing that I’m not doing?

My products are set up with the MSRP price. So, I have price mapped to MSRP.

Special prices are not set on a per product basis, but with catalog price rules, this is where I set my discount.

I tried the above code, I deleted 30 products from google base, and then added them and then published. I still see Price the same as Original Price.

Any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
dixo5
Jr. Member
 
Total Posts:  11
Joined:  2010-01-27
 

@ leomoon88…
you\’re totally wrong, in editing the item.php you can send everything you want to google.. i send for example meta_title and short_description and not the name & the description.

@ mgarratt
I tried your sniplet for the price rules but everytime i get a parse error, unexpected T_Variable ... but i don´t see any error, your code appears to be right… andy ideas ?

using magento 1.4.1.1

 
Magento Community Magento Community
Magento Community
Magento Community
 
IndustrialLive
Jr. Member
 
Total Posts:  10
Joined:  2010-04-26
 

Can anyone supply me with the latest full script for exporting products to Google Base for Shopping integration.  We’ve been struggling for weeks with a way to do this and just need to start over from scratch, so I need a basic file gbase.php file set for Magento back-end.  I can then change all the settings for my site and see if it works any better.

We also use the “special_price” for some, but not all, products!

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
benh777
Jr. Member
 
Total Posts:  30
Joined:  2009-07-31
 

I’m running Magento 1.4.2 and have tried nearly every snippet of code from this thread in Item.php but with no luck.

Even when I add this code

$this->_setAttributePrice(false$object->getSpecialPrice());
Instead of getPrice
Delete a product in Google Base which has a special price, synchronise Google Base with Magento, then add that single product to Google Base again, it still shows the normal price!

Anyone know why this doesn’t work?  Do I need to refresh some kind of core code cache or something?

Has anyone managed to fix this in 1.4.2?

Many Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
benh777
Jr. Member
 
Total Posts:  30
Joined:  2009-07-31
 

Just managed to fix it.

I had to take out the Price > price mapping in Google Base > Manage Attributes.
Then delete the items from Google Base, and re \’Add to Google Base\’ them.

I added this code to app/code/local/Mage/GoogleBase/Model/Service/Item.php

if (isset($attributeValues[\'price\'][\'value\']) && floatval($attributeValues[\'price\'][\'value\']) > 0{
            $price 
$attributeValues[\'price\'][\'value\'];
        
else {
            
// Initialise array, add standard Price
            
$min_values = array();
            
$min_values[] $object->getPrice();
            
            
// If Special Price is set, add to array
            
if($object->getSpecialPrice() > 0{ $min_values[] $object->getSpecialPrice(); }
            
            
// Get Catalog Price Rule Price
            
$write Mage::getSingleton(\'core/resource\')->getConnection(\'core_write\');
            
$readresult=$write->query(\"SELECT rule_price FROM catalogrule_product_price WHERE product_id = \".$object->getId().\" ORDER BY rule_product_price_id DESC LIMIT 1 \");
            
// If a result is returned, add to array
            
while ($row $readresult->fetch() ) { $min_values[] $row[\'rule_price\']
            
            
// Set price for GoogleBase to minimum of 3 prices
            
$price min($min_values);
        
}

        $this
->_setAttributePrice(false$price);

Thankyou mgarratt for the code.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top