TaxProxy calls calculateProductTax wrongly
blackgearit opened this issue · comments
I'm new with VSF and Shopware, I'm trying to set-up a dev environment.
I've noticed this error from api after shopware data-import to elastic, when i made a product search into the frontend:
vue-storefront-api | TypeError: Cannot read property 'tax_class_id' of undefined
vue-storefront-api | at Object.calculateProductTax (/var/www/src/lib/taxcalc.js:160:15)
vue-storefront-api | at TaxProxy.taxFor (/var/www/src/platform/shopware/tax.js:55:12)
vue-storefront-api | at /var/www/src/platform/shopware/tax.js:94:18
vue-storefront-api | at process._tickCallback (internal/process/next_tick.js:68:7)
and no items where listed in the results.
looking into vue-storefront-api/src/platform/shopware/tax.js
(copied from shopware2vuestorefront/vsf-api-extension/tax.js
)
taxFor (product) {
return calculateProductTax(product, this._taxClasses, this._taxCountry, this._taxRegion, this._sourcePriceInclTax)
}
should be
taxFor (product) {
return calculateProductTax({
product: product,
taxClasses: this._taxClasses,
taxCountry: this._taxCountry,
taxRegion: this._taxRegion,
sourcePriceInclTax: this._sourcePriceInclTax
})
}
because the taxFor
function's parameter is an object:
vue-storefront-api/src/lib/taxcalc.js
export function calculateProductTax ({ product, taxClasses, taxCountry = 'PL', taxRegion = '', sourcePriceInclTax = false, deprecatedPriceFieldsSupport = false, finalPriceInclTax = true, userGroupId = null, isTaxWithUserGroupIsActive }) {
After this change, the product search works.