-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variants should support unique MPN #33
Comments
|
Thanks for the feedback. What I am referring to is the exception MissingIdentifierException: Please define a GTIN or MPN value before creating a variant. which is thrown if I try to create the variant without setting the MPN first. I may just be overlooking something but this is what my code looks like...
|
If you are creating variants, then just call the MPN anything, it is only used for the group identifier as the initial object should be destroyed; foreach($products as $product)
{
$product_link = $store['domain'] . '/products/' . $product['handle'];
$product_image = $product['image']['src'];
$item = GoogleShopping::createItem();
$item->id($product['id']);
$item->title($product['title']);
$item->description($product['body_html']);
$item->link($product_link);
$item->image_link($product_image);
$item->mpn(substr(0, 8, sha1($product['id'])));
foreach ($product['variants'] as $variant)
{
$v = $item->variant();
$v->mpn($variant->sku);
}
$item->delete();
} |
According to the Google documentation, it says "Typically, each variant of a product (different colors or sizes) has its own MPN, so make sure to submit the correct value."
The function variant() in this library calls getGroupIdentifier() which requires an MPN (or GTIN) already be set before it can create the variant, meaning it is using the same one for all variants.
How can this be fixed?
The text was updated successfully, but these errors were encountered: