Magento allows you to disable Google checkout functionality for each product. Under certain situations though (when upgrading from 1.2 to 1.3 for example), the state of your products eligibility for sale through Google Checkout changes.
If you find yourself unable to sell products through Google checkout you can easily enable Google Checkout for your products through the Magento admin interface. However if you have many hundreds or thousands of products going through each one is not an option.
Here is a solution that will allow you to set the state of all your products to enabled for Google Checkout, quickly and easily. Testing has been limited to my own development installation, so as always backup your data before running anything.
In our 1.2 Magento databse the EAV attribute is called disable_googlecheckout
but in Magento 1.3 it is called enable_googlecheckout
. You’ll need to know which version you are working on before proceeding with the steps below. To check run the following SQL query and take note of the attribute_code
and attribute_id
:
SELECT * FROM eav_attribute WHERE attribute_code LIKE "%google%"\G |
You could run an SQL query at this point to update(or insert if it is missing) a value of each row in the catalog_product_entity_int
table where the attribute_id
is the value you see in the above query. It may be that the SQL method is required for really big inventories, and if that is the case then someone please comment and let me know.
I have quickly written a little PHP solution quick fix hack that will update the Google Checkout enabled state for your products in Magento. I think this will be an easier to use solution for most people out there, simply drop the file into the root of your Magento store and either browse to it or run it on the command line.
The code to make the change is this:
<?php /* * Quick little file to set all of your products to enabled for Google checkout. * Run it in the root of your Magento directory. * * Author: Ashley Schroder (ashley.schroder (at) gmail.com) * More information see aschroder.com * */ set_time_limit(0); require_once 'app/Mage.php'; Mage::app('default'); try{ $products = Mage::getModel('catalog/product')->getCollection(); $prodIds=$products->getAllIds(); $product = Mage::getModel('catalog/product'); $count = 0; foreach($prodIds as $productId) { $product->load($productId); $product->setEnableGooglecheckout(false); $product->save(); $count++; } echo "Update complete. ". $count." records saved."; } catch(Exception $e){ die($e->getMessage()); } ?> |
Create a file called say ‘undisable-google-checkout.php’ and place the code into it. Simply FTP, SCP or otherwise transfer it to the root directory of your Magento installation. You can run it by browsing to the script via yourstore.com/undisable-google-checkout.php or run it on the command-line as per the example below:
php -f undisable-google-checkout.php |
One thing to note – it will only work for v1.3 currently, if you want this on version 1.2 of Magento then you will need to change this line:
$product->setEnableGooglecheckout(true); |
to this one because the attribute is named differently before Magento version 1.3:
$product->setDisableGooglecheckout(false); |
I’m really keen to hear feedback on this because a) I have only tested it quickly on my database with a handful of products in it, and b) I don’t normally write little php files like this to make these sorts of changes, but thought I’d give it a try as a way to allow others to fix their Magento Google Checkout quickly without having to run DB queries themselves.
I found I had to change the script to this for it to work with the most recent version of magento (1.3.2.1)
setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$products = Mage::getModel(‘catalog/product’)->getCollection();
$prodIds=$products->getAllIds();
$product = Mage::getModel(‘catalog/product’);
$count = 0;
foreach($prodIds as $productId) {
$product->load($productId);
$product->setEnableGooglecheckout(true);
$product->save();
$count++;
}
echo “Update complete. “. $count.” records saved.”;
?>
Guys – thanks for the help on this one…just updated a client from 1.1.8 to 1.3.2.4 and suddenly saw all the Google checkout buttons greyed. :/
Anyways, had to tweak Ashley’s script slightly, what worked follows:
set_time_limit(0);
require_once ‘app/Mage.php’;
Mage::app(‘default’);
try{
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$products = Mage::getModel(‘catalog/product’)->getCollection();
$prodIds=$products->getAllIds();
$product = Mage::getModel(‘catalog/product’);
$count = 0;
foreach($prodIds as $productId) {
$product->load($productId);
$product->setEnableGooglecheckout(true);
$product->save();
$count++;
}
echo “Update complete. “. $count.” records saved.”;
}
catch(Exception $e){
die($e->getMessage());
}
This is odd: I’m getting an Abstract error.
Warning: Invalid argument supplied for foreach() in /app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 970
That is odd… what version of Magento are you on?
Does anyone know how to do this with magento 1.4? I tried using johns script, but the browser just kept processing and never ended up doing anything.
Hi, Big thanks, BIG
Can we set the var to tax to enable all to one tax class or disable or enable for all products ?
Can you please update the script for 1.4.1 ?
Thanks!
Direct SQL
UPDATE catalog_product_entity_int SET `value`=1 WHERE attribute_id=(SELECT attribute_id FROM eav_attribute WHERE attribute_code LIKE ‘enable_googlecheckout’); #114
SELECT * FROM `itmanx_magento`.`catalog_product_entity_int`
LEFT JOIN eav_attribute USING (attribute_id)
WHERE attribute_code LIKE ‘enable_googlecheckout’
opps, i left our table name in there. you need to replace itmanx_magento with your own table name or remove it all together (including the dot)