getcandy / hub

GetCandy v1 Hub built on Nuxt.js
30 stars 9 forks source link

Managing availability and pricing on products result in a client error #5

Closed Repox closed 4 years ago

Repox commented 4 years ago

Accessing catalogue-manager/products/{hashid}/availability-pricing in the hub results in the client presenting a red dialog box with the header "Internal Server Error" and message "Cannot read property 'id' of undefined"

alecritson commented 4 years ago

I wasn't able to reproduce this one, can you let me know if it's still an issue after upgrading.

Repox commented 4 years ago

This is still an issue after upgrading.

This is the error I get:

TypeError: Cannot read property 'id' of null         client.js?06a0:84
    at Proxy.render (VariantManager.vue?0bf7:313)
    at VueComponent.Vue._render (vue.common.dev.js?4650:3547)
    at VueComponent.updateComponent (vue.common.dev.js?4650:4052)
    at Watcher.get (vue.common.dev.js?4650:4474)
    at Watcher.run (vue.common.dev.js?4650:4549)
    at flushSchedulerQueue (vue.common.dev.js?4650:4307)
    at Array.eval (vue.common.dev.js?4650:1985)
    at flushCallbacks (vue.common.dev.js?4650:1911)
alecritson commented 4 years ago

This is on a draft/recently published/live product?

if you could share the steps you took to get to this that'd be awesome

Repox commented 4 years ago

It's the same result whether it's an already published product or a a draft.

Here's a gif showing my exact process.

Here's a dump of the server response:

{
    "data": {
        "id": "xgwl53rj",
        "drafted_at": null,
        "option_data": [],
        "created_at": "2020-06-11T07:27:15.000000Z",
        "updated_at": "2020-06-11T07:27:15.000000Z",
        "attribute_data": {
            "name": {
                "webstore": {
                    "en": "mollitia labore quas assumenda"
                }
            }
        },
        "attributes": {
            "data": []
        },
        "draft": {
            "data": null
        },
        "layout": {
            "data": null
        },
        "published_parent": {
            "data": null
        },
        "assets": {
            "data": []
        },
        "family": {
            "data": {
                "id": "8edoldnr",
                "name": "Default",
                "attribute_data": null,
                "attributes": {
                    "data": [{
                        "id": "dnj4zky5",
                        "name": {
                            "en": "Name"
                        },
                        "handle": "name",
                        "position": "1",
                        "filterable": false,
                        "scopeable": true,
                        "translatable": true,
                        "variant": false,
                        "searchable": true,
                        "localised": true,
                        "type": "text",
                        "required": true,
                        "lookups": [],
                        "system": false,
                        "attribute_data": null,
                        "group": {
                            "data": {
                                "id": "vokq5kmj",
                                "name": {
                                    "en": "Marketing"
                                },
                                "handle": "marketing",
                                "position": "1",
                                "attribute_data": null
                            }
                        }
                    }, {
                        "id": "l9kwmjxg",
                        "name": {
                            "en": "Page Title"
                        },
                        "handle": "page_title",
                        "position": "1",
                        "filterable": false,
                        "scopeable": true,
                        "translatable": true,
                        "variant": false,
                        "searchable": true,
                        "localised": true,
                        "type": "text",
                        "required": true,
                        "lookups": [],
                        "system": false,
                        "attribute_data": null,
                        "group": {
                            "data": {
                                "id": "mqkj8wyj",
                                "name": {
                                    "en": "SEO"
                                },
                                "handle": "seo",
                                "position": "2",
                                "attribute_data": null
                            }
                        }
                    }, {
                        "id": "m62zpkyw",
                        "name": {
                            "en": "Short Description"
                        },
                        "handle": "short_description",
                        "position": "2",
                        "filterable": false,
                        "scopeable": true,
                        "translatable": true,
                        "variant": false,
                        "searchable": true,
                        "localised": true,
                        "type": "textarea",
                        "required": false,
                        "lookups": [],
                        "system": false,
                        "attribute_data": null,
                        "group": {
                            "data": {
                                "id": "vokq5kmj",
                                "name": {
                                    "en": "Marketing"
                                },
                                "handle": "marketing",
                                "position": "1",
                                "attribute_data": null
                            }
                        }
                    }, {
                        "id": "rm2qvk61",
                        "name": {
                            "en": "Meta description"
                        },
                        "handle": "meta_description",
                        "position": "2",
                        "filterable": false,
                        "scopeable": true,
                        "translatable": true,
                        "variant": false,
                        "searchable": true,
                        "localised": true,
                        "type": "textarea",
                        "required": false,
                        "lookups": [],
                        "system": false,
                        "attribute_data": null,
                        "group": {
                            "data": {
                                "id": "mqkj8wyj",
                                "name": {
                                    "en": "SEO"
                                },
                                "handle": "seo",
                                "position": "2",
                                "attribute_data": null
                            }
                        }
                    }, {
                        "id": "elkrok08",
                        "name": {
                            "en": "Description"
                        },
                        "handle": "description",
                        "position": "3",
                        "filterable": false,
                        "scopeable": true,
                        "translatable": true,
                        "variant": false,
                        "searchable": true,
                        "localised": true,
                        "type": "richtext",
                        "required": false,
                        "lookups": [],
                        "system": false,
                        "attribute_data": null,
                        "group": {
                            "data": {
                                "id": "vokq5kmj",
                                "name": {
                                    "en": "Marketing"
                                },
                                "handle": "marketing",
                                "position": "1",
                                "attribute_data": null
                            }
                        }
                    }, {
                        "id": "z7270k8d",
                        "name": {
                            "en": "Meta Keywords"
                        },
                        "handle": "meta_keywords",
                        "position": "3",
                        "filterable": false,
                        "scopeable": true,
                        "translatable": true,
                        "variant": false,
                        "searchable": true,
                        "localised": true,
                        "type": "text",
                        "required": false,
                        "lookups": [],
                        "system": false,
                        "attribute_data": null,
                        "group": {
                            "data": {
                                "id": "mqkj8wyj",
                                "name": {
                                    "en": "SEO"
                                },
                                "handle": "seo",
                                "position": "2",
                                "attribute_data": null
                            }
                        }
                    }]
                }
            }
        },
        "routes": {
            "data": [{
                "id": "r9n3dq16",
                "default": true,
                "redirect": false,
                "locale": "en",
                "path": null,
                "slug": "quam-consequatur-fuga-dignissimos-dicta-iusto-corporis-nostrum",
                "description": null,
                "type": "product",
                "attribute_data": null,
                "element": []
            }]
        },
        "channels": {
            "data": [{
                "id": "y3g6v91o",
                "name": "webstore",
                "handle": "webstore",
                "url": "http:\/\/localhost",
                "default": true,
                "published_at": "2020-06-11T07:27:15+00:00",
                "attribute_data": null
            }]
        },
        "categories": {
            "data": []
        },
        "variants": {
            "data": [{
                "id": "xgwl53rj",
                "sku": "amet-voluptatem-67",
                "backorder": "always",
                "requires_shipping": true,
                "price": 2844,
                "factor_tax": 0,
                "unit_price": 2844,
                "total_tax": 0,
                "unit_tax": 0,
                "unit_qty": 1,
                "min_qty": 1,
                "max_qty": 0,
                "min_batch": 1,
                "inventory": 1,
                "incoming": 0,
                "group_pricing": false,
                "weight": {
                    "value": "0.00000",
                    "unit": "kg"
                },
                "height": {
                    "value": "0.00000",
                    "unit": "cm"
                },
                "width": {
                    "value": "0.00000",
                    "unit": "cm"
                },
                "depth": {
                    "value": "0.00000",
                    "unit": "cm"
                },
                "volume": {
                    "value": "0.00000",
                    "unit": "l"
                },
                "options": [],
                "attribute_data": null,
                "product": {
                    "data": {
                        "id": "xgwl53rj",
                        "drafted_at": null,
                        "option_data": [],
                        "created_at": "2020-06-11T07:27:15.000000Z",
                        "updated_at": "2020-06-11T07:27:15.000000Z",
                        "attribute_data": {
                            "name": {
                                "webstore": {
                                    "en": "mollitia labore quas assumenda"
                                }
                            }
                        },
                        "draft": [],
                        "layout": [],
                        "published_parent": []
                    }
                },
                "image": null,
                "tiers": {
                    "data": []
                },
                "customer_pricing": {
                    "data": []
                },
                "tax": {
                    "data": null
                }
            }]
        },
        "collections": {
            "data": []
        },
        "associations": {
            "data": []
        },
        "versions": {
            "data": []
        },
        "customer_groups": {
            "data": [{
                "id": "v8l4pl01",
                "name": "Retail",
                "handle": "retail",
                "visible": 1,
                "purchasable": 1,
                "attribute_data": null
            }, {
                "id": "p09prlrn",
                "name": "Guest",
                "handle": "guest",
                "visible": 1,
                "purchasable": 1,
                "attribute_data": null
            }]
        }
    }
}
alecritson commented 4 years ago

Looks like the variant hasn't got a tax id associated to it, I assume this is from the seeder. The hub should better handle this thought but for the moment does something like

update product_variants set tax_id = 1

Solve the issue?

alecritson commented 4 years ago

Pushed an update on the products module, should tackle this

npm update @getcandy/hub-products
Repox commented 4 years ago

Adding a tax_id to the product_variants solved the issue.

Updated the products module and things worked like expected.