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

Export Module for Google Base
 
John R
Sr. Member
 
Total Posts:  90
Joined:  2008-08-21
 

Here is one more addition that needs to be made in order for it to pull Special Pricing (if it exists)

Line ~41

if($product->getSpecialPrice())
                
$product_data['price']=$product->getSpecialPrice();
            else
                
$product_data['price']=$product->getPrice();
 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

@John
Awesome mod grin

 
Magento Community Magento Community
Magento Community
Magento Community
 
John R
Sr. Member
 
Total Posts:  90
Joined:  2008-08-21
 

Any idea how to grab associated products from a Grouped Product ID #?

 
Magento Community Magento Community
Magento Community
Magento Community
 
seudo
Guru
 
Avatar
Total Posts:  344
Joined:  2008-04-21
 

@John R - The closest thing I could find and get a response was here: http://www.magentocommerce.com/boards/viewthread/19867/. Maybe it might help.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alex.bsc
Guru
 
Total Posts:  340
Joined:  2008-06-06
 

great stuff re: special price. however, it does not seem to work when there is a store-wide category price rule, and presume it does not work with caregory rules at all.

is anyone else finding this is true?

 
Magento Community Magento Community
Magento Community
Magento Community
 
alex.bsc
Guru
 
Total Posts:  340
Joined:  2008-06-06
 

turbo1: have you considered submitting your script to be included as part of magento core?
streamlined and integrated into core, all credits to yours truly? wink

ditto with your other contributions..
much respect again for getting this commissioned. i’m finding i’m on the bleeding edge of required functionality in the sense that functionality in magento is being developed just as i require it! wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

I haven’t thought much about submitting it smile I didn’t author the script, so all credit should really go to Anda.  grin

And yes, it probably does not work with special price rules or grouped products. It was written specifically for my (very basic) store. I have only simple products and no special pricing anywhere.  But everyone is free to modify the script to be more robust!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Oldgamer
Sr. Member
 
Avatar
Total Posts:  142
Joined:  2008-09-12
 
John R - 14 October 2008 12:57 PM

Here is one more addition that needs to be made in order for it to pull Special Pricing (if it exists)

Line ~41

if($product->getSpecialPrice())
                
$product_data['price']=$product->getSpecialPrice();
            else
                
$product_data['price']=$product->getPrice();

I am not sure why, but I just realized that after I made that change, my prices became a mess, very strange.
It looks like special prices are fine.

the code now looks like this (I believe I made correct changes):
...
$product_data = array();
$product_data[’sku’]=$product->getSku();
$product_data[’title’]=$product->getName();
$product_data[’description’]=$product->getDescription();
$product_data[’link’]=$product->getProductUrl(); $product_data[’image_link’]=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).’catalog/product’.$product->getImage();
if($product->getSpecialPrice())
$product_data[’price’]=$product->getSpecialPrice();
else
$product_data[’price’]=$product->getPrice();

$product_data[’brand’]=$product->getResource()->getAttribute(’manufacturer’)->getFrontend()->getValue($product);
$product_data[’product_type’]=’’;
$product_data[’expiration_date’]=$expiration_date;

Thanks for any help.

P.S. I changed code back as it was before, and now prices are correct, but sure I miss a special prices.
I don’t know why function getSpecialPrice() doesn’t give correct result or something wrong with the code…

 
Magento Community Magento Community
Magento Community
Magento Community
 
John R
Sr. Member
 
Total Posts:  90
Joined:  2008-08-21
 

EDIT: See next page

 
Magento Community Magento Community
Magento Community
Magento Community
 
Oldgamer
Sr. Member
 
Avatar
Total Posts:  142
Joined:  2008-09-12
 

Yes, it looks pretty much same as mine, except I added couple more fields, but they are fine and not related to prices anyhow.
Now I added pull out special price as separate column in a file and got two columns: price and special. The thing is that function special gave me “special” even it is was not used. It gave me values which looks like prices, something like 6.99 or 19.99 for example. Looks like from not cleared memory or something, I do not know.
I do not know how function works, but you check that function as a Boolean, which is probably not right. :(

P.S. Some update:
I noticed that function getSpecial return the last special price for the product when it called like that. So, if all products have special prices, it will give you correct result. Otherwise it will return the last result which is more than zero.
I checked the file I got and what I noticed: (I added second column, special, just to check what function returns):
all product specials were zero until first product in a list which has special price. Then, function returned same special price as for first product for all next products until next product which has other special price. And so on. So, all products in between, got special prices of previous product… I do not know how function can be “reset ted” after every call.

 
Magento Community Magento Community
Magento Community
Magento Community
 
alex.bsc
Guru
 
Total Posts:  340
Joined:  2008-06-06
 

Looking good, John R.

I am trying to figure out how to draw out the catalog price rules prices from products. I am currently running a 10% store sale on and the lowered prices are not reflected in the Google Base module.

What is the method that will return the catalog price rules price?

 
Magento Community Magento Community
Magento Community
Magento Community
 
John R
Sr. Member
 
Total Posts:  90
Joined:  2008-08-21
 

@ Oldgamer:

EDIT: SEE NEXT PAGE

@ alex.bsc

That’s a tricky one. I don’t use any catalog price rules, but I will make some on my test store and see if I can figure it out. I have one theory but no guarantees if it’s going to work.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Oldgamer
Sr. Member
 
Avatar
Total Posts:  142
Joined:  2008-09-12
 
John R - 27 October 2008 11:20 AM

@ Oldgamer:

I am short-hand checking for whether or not

if($product->getSpecialPrice())

exists or not. If it does, that means it has a special price, and it uses the special. if it doesn’t, it uses the regular price. Isn’t this the functionality you want?…

Sure, this is functionality I want.
The thing is: your code is good, function getSpecialPrice() itself is not really. But I guess in the next version of Magento it will be corrected.
I posted about it here:
getSpecialPrice() Issue

so you will understand what I’m talking about.

 
Magento Community Magento Community
Magento Community
Magento Community
 
John R
Sr. Member
 
Total Posts:  90
Joined:  2008-08-21
 

The Magento team member in the issue tracker did address the issue properly. As soon as you move that line inside the loop, it works using my original code modification.

New full code:

<?php
    define
('SAVE_FEED_LOCATION','export/google_base_feed.txt');

    
set_time_limit(0);    

    require_once 
'app/Mage.php';
        
Mage::app('default');
        
    
try{
        $handle 
fopen(SAVE_FEED_LOCATION'w');

        
        
$heading = array('id','title','description','link','image_link','price','brand','product_type','payment_accepted','tax');
        
$feed_line=implode("\t"$heading)."\r\n";
        
fwrite($handle$feed_line);

        
$products Mage::getModel('catalog/product')->getCollection();
        
$products->addAttributeToFilter('status'1);//enabled
        
$products->addAttributeToFilter('visibility'4);//catalog, search
        
$products->addAttributeToFilter('type_id''simple');//simple only (until fix is made)
        
$products->addAttributeToSelect('*');
        
$prodIds=$products->getAllIds();
        
        
        
        
        foreach(
$prodIds as $productId{

            $product 
Mage::getModel('catalog/product'); // <------- the problem line
            
            
$product->load($productId);
            
            
$product_data = array();    
            
$product_data['sku']=$product->getSku();    
            
$product_data['title']=$product->getName();
            
$product_data['description']=$product->getDescription();
            
$product_data['link']=$product->getProductUrl();
            
$product_data['image_link']=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();

            if(
$product->getSpecialPrice())
                
$product_data['price']=$product->getSpecialPrice();
            else
                
$product_data['price']=$product->getPrice();
            
            
$product_data['brand']=$product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);    
            
$product_data['product_type']='';        

                
            foreach(
$product->getCategoryIds() as $_categoryId){
                $category 
Mage::getModel('catalog/category')->load($_categoryId);
                
$product_data['product_type'].=$category->getName().', ';
            
}
            $product_data[
'product_type']=rtrim($product_data['product_type'],', ');        

            
$product_data['payment_accepted''Visa, Mastercard, AmericanExpress, Discover, GoogleCheckout';
            
$product_data['tax''US:MI:6.00:n';
            
            
//sanitize data    
            
foreach($product_data as $k=>$val){
            $bad
=array('"',"\r\n","\n","\r","\t");
            
$good=array(""," "," "," ","");
            
$product_data[$k] '"'.str_replace($bad,$good,$val).'"';
            
}
            

            $feed_line 
implode("\t"$product_data)."\r\n";
            
fwrite($handle$feed_line);
            
fflush($handle);
        
}

        
//---------------------- WRITE THE FEED    
        
fclose($handle);
        
    
}
    
catch(Exception $e){
        
die($e->getMessage());
    
}

Now getSpecialPrice() is in fact null if there is no special price!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Oldgamer
Sr. Member
 
Avatar
Total Posts:  142
Joined:  2008-09-12
 

John,
sorry, I’m not following.
What I was saying is that function itself was not given correct value, it has nothing to do with your code. Your code was and is correct, as I know (I’m not a php programmer, though).
I can not see a difference between code you just posted and code before.
Thanks.

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