Include shipping weight details in product data - #107
Conversation
Added shipping weight details for Google Merchant, formatted as a string with 6 decimal places. Included condition to check for product weight before adding to data.
|
@Andrew998 Thanks for the contribution. This should respect the module config: Also, why rounding to 6 decimal places? Magneto rounds to 4 decimal places, so this seems unnecessary. |
|
Thanks. I'm not too familiar with coding for Magento so all comments are welcome. Is the process that I make those changes to the contribution? |
|
Hi Andrew, Yes please go ahead and update your merge request and we will review it again for you. If not, we can put it in our roadmap to implement at a later date. |
…y weight. Updated weight formatting to use 4 decimal places instead of 6. Update check for display weight.
Corrected comment to specify weight formatting with 4 decimal places.
|
The latest commit removes the check for a valid weight on the product. As well as checking if the config allows weight to be included, you must still check that a weight existing on the product. See the short description as an example of this logic. |
Add weight check to include shipping details for products.
|
Thank you. I'll get there eventually! |
Updated weight formatting to use 6 decimal places instead of 4.
Andrew998
left a comment
There was a problem hiding this comment.
This is ready for review. Shipping weight is the one thing missing for Google Merchant account to pick up all details without needing a feed.
Code Review SummaryStatus: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (1 file)
Fix these issues in Kilo Cloud Previous Review Summary (commit bb689e3)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit bb689e3)Status: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (1 file)
Reviewed by gpt-5.6-luna · Input: 30 · Output: 9.3K · Cached: 234.2K |
|
Should this be using QuantitativeValue? i.e. something like: if ($product->getWeight() !== null && $product->getWeight() !== '') {
$data['shippingDetails'] = [
'@type' => 'OfferShippingDetails',
'weight' => [
'@type' => 'QuantitativeValue',
'value' => (float)$product->getWeight(),
'unitText' => $this->getConfig('general/locale/weight_unit')
]
];
} |
|
I don't believe so. I have been using it as it is for 6 months now and Google Merchant Centre now lists all products as fully approved without having to provide a feed. Without this addition, they are not fully approved. |
|
The official spec claims it is required, so it would be best to migrate to that format. https://schema.org/OfferShippingDetails Please also add the same check used elsewhere to gate this logic: Then this should be good for merge. |
|
Thank you. I will do some further testing and check it all works. |
Added shipping weight details for Google Merchant, formatted as a string with 6 decimal places. Included condition to check for product weight before adding to data.