bluevisiontec / GoogleShoppingApi

Magento Module GoogleShoppingApi v2
Open Software License 3.0
69 stars 45 forks source link

Missing 'shipping weight' attribute. #90

Closed jrmoore5 closed 5 years ago

jrmoore5 commented 7 years ago

I recently installed the API but am continually getting this message when trying to add a product to Google Shopping...

"Error calling POST https://www.googleapis.com/content/v2/109455174/products: (400) [shipping_weight] validation/missing_recommended for Shopping: Missing 'shipping weight' attribute."

...I've tried linking Weight with Shipping Weight, and with that not working I tried to add a specific attribute to that product "shipping_weight" with still no change in the error response. I think I'm missing something small but perhaps someone has run into a similar issue?

jrmoore5 commented 7 years ago

So digging more into this it's due to configurable product pulling weight from simple product I believe, as I was able to add weight to the configurable and skip this error. I am however coming across an issue with size because that is necessary to pull from the simple products and they don't seem to be pulling properly.

jrmoore5 commented 7 years ago

Just an update for configurable products - this probably isn't the best solution but I figured a little bit out. This applied to me specifically for Size but you could easily apply it to things like weight, or any of your options that generate your configurable product as long as you don't mind somewhat of a hardcoded name. If you find this is completely wrong let me know, I'm not a expert in magento by any means.

**Disclaimer: Google wants you to upload all your simple products with their own GTIN, rather than a configurable product with multiple GTIN.

I'm going to rewrite some of the code to pull configurable product fields for Simple Products (ie. sale price, price) and a quick search you can find url forwarding from simple to configurable with options selected**

app/code/community/BlueVisionTec/GoogleShoppingApi/Model/Attribute/Size.php

Replace Line 42 with... $shoppingProduct->setSizes($value);

Replace lines 33-36 with...

$attrs  = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
foreach($attrs as $attr) {
    if(strpos($attr["attribute_code"], "size")!== false) {
        $options = $attr["values"];

        foreach($options as $option) {
            $value[] = $option["store_label"];
        }
    }
}

Another thing to note: You have to map something on the configurable product to even hit the file the way it's currently set up, if you link something only editable on the simple product it'll never call the file.