0

I haven't had any problems but I moved to a new server and really haven't check it out for a while but now when I try to add a product to google shopping I get the following error:

Recoverable Error: Object of class Mage_Catalog_Model_Resource_Eav_Attribute could not be converted to string in /home/xxxxxxx/public_html/app/code/community/BlueVisionTec/GoogleShoppingApi/Model/Attribute/GoogleProductCategory.php on line 30

Here is the code the error is pointing to:

    public function convertAttribute($product, $shoppingProduct)
    {   
        // get category from product attribute
  -- line 30 here -->   Mage::log(__LINE__.$product->getResource()->getAttribute('google_shopping_category'));
        $value = $product->getResource()->getAttribute('google_shopping_category')
        ->getFrontend()->getValue($product);
        $value = preg_replace('/\d+ /','',$value);
        $shoppingProduct->setGoogleProductCategory($value);

        return $shoppingProduct;
    }

I've tried many things (mostly guesses) searched on Google and still can't seem to fix this error. Any help would be very much appreciated.

1 Answer 1

1

$product->getResource()->getAttribute('google_shopping_category') returns an instance of Mage_Catalog_Model_Resource_Eav_Attribute and when you are doing this __LINE__.$product->getResource()->getAttribute('google_shopping_category') PHP tries to automatically convert the instance of Mage_Catalog_Model_Resource_Eav_Attribute to a string and it cannot do that.
An alternative would be to replace that with

$id = $product->getResource()->getAttribute('google_shopping_category')->getId();
Mage::log(__LINE__.$id);  

Or, of you need full details of the attribute you can try.

$attributeAsString = print_r($product->getResource()->getAttribute('google_shopping_category'), true);
Mage::log(__LINE__.$attributeAsString); 
2
  • I think that fixed the problem but I ran into another problem but that error is gone. Let me see...
    – Freejoy
    Commented Mar 14, 2017 at 10:56
  • That got it! Thanks. I had another little problem with one of my attributes not being Google correct.
    – Freejoy
    Commented Mar 14, 2017 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.