NVision-Commerce-Solutions / module-customer-price

Commerce 365 for Magento - Magento 2 Extension - Customer Price Module
https://n.vision/products/commerce-365-for-magento-b2b/
2 stars 4 forks source link

Undefined array key "uoM" #6

Closed gerrits-ecommerce closed 1 year ago

gerrits-ecommerce commented 1 year ago

After updating to version 1.1.0 we got an error on the category page preventing products from loading and adding them to the cart.

{"0":"Warning: Undefined array key \"uoM\" in \/data\/web\/1680599951\/vendor\/commerce365\/module-customer-price\/Service\/Additional\/AdditionalDataBuilder.php on line 23","1":"#1 Rollbar\\Handlers\\ErrorHandler->handle() called at [vendor\/commerce365\/module-customer-price\/Service\/Additional\/AdditionalDataBuilder.php:23]\n#2 Commerce365\\CustomerPrice\\Service\\Additional\\AdditionalDataBuilder->build() called at [vendor\/commerce365\/module-customer-price\/Service\/Mapper\/ResponseToDatabaseMapper.php:73]\n#3 Commerce365\\CustomerPrice\\Service\\Mapper\\ResponseToDatabaseMapper->getPriceData() called at [vendor\/commerce365\/module-customer-price\/Service\/Mapper\/ResponseToDatabaseMapper.php:44]\n#4 Commerce365\\CustomerPrice\\Service\\Mapper\\ResponseToDatabaseMapper->map() called at [vendor\/commerce365\/module-customer-price\/Service\/SyncPrices.php:36]\n#5 Commerce365\\CustomerPrice\\Service\\SyncPrices->execute() called at [vendor\/commerce365\/module-customer-price\/Service\/GetPriceCollectionForProducts.php:63]\n#6 Commerce365\\CustomerPrice\\Service\\GetPriceCollectionForProducts->getCollectionFromERP() called at [vendor\/commerce365\/module-customer-price\/Service\/GetPriceCollectionForProducts.php:45]\n#7 Commerce365\\CustomerPrice\\Service\\GetPriceCollectionForProducts->execute() called at [vendor\/commerce365\/module-customer-price\/Service\/GetProductPriceData.php:27]\n#8 Commerce365\\CustomerPrice\\Service\\GetProductPriceData->execute() called at [vendor\/commerce365\/module-customer-price\/Service\/GetPriceForQuantity.php:29]\n#9 Commerce365\\CustomerPrice\\Service\\GetPriceForQuantity->execute() called at [vendor\/commerce365\/module-customer-price\/Plugin\/Frontend\/SimplePricePlugin.php:51]\n#10 Commerce365\\CustomerPrice\\Plugin\\Frontend\\SimplePricePlugin->afterGetTierPrice() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:146]\n#11 Magento\\Catalog\\Model\\Product\\Type\\Price\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#12 Magento\\Catalog\\Model\\Product\\Type\\Price\\Interceptor->___callPlugins() called at [generated\/code\/Magento\/Catalog\/Model\/Product\/Type\/Price\/Interceptor.php:59]\n#13 Magento\\Catalog\\Model\\Product\\Type\\Price\\Interceptor->getTierPrice() called at [vendor\/magento\/module-catalog\/Model\/Product.php:1188]\n#14 Magento\\Catalog\\Model\\Product->getTierPrice() called at [generated\/code\/Magento\/Catalog\/Model\/Product\/Interceptor.php:383]\n#15 Magento\\Catalog\\Model\\Product\\Interceptor->getTierPrice() called at [vendor\/magento\/module-catalog\/Model\/Product\/Type\/Price.php:257]\n#16 Magento\\Catalog\\Model\\Product\\Type\\Price->_applyTierPrice() called at [vendor\/magento\/module-catalog\/Model\/Product\/Type\/Price.php:153]\n#17 Magento\\Catalog\\Model\\Product\\Type\\Price->getBasePrice() called at [generated\/code\/Magento\/Catalog\/Model\/Product\/Type\/Price\/Interceptor.php:32]\n#18 Magento\\Catalog\\Model\\Product\\Type\\Price\\Interceptor->getBasePrice() called at [vendor\/magento\/module-catalog\/Model\/Product\/Type\/Price.php:171]\n#19 Magento\\Catalog\\Model\\Product\\Type\\Price->getFinalPrice() called at [generated\/code\/Magento\/Catalog\/Model\/Product\/Type\/Price\/Interceptor.php:41]\n#20 Magento\\Catalog\\Model\\Product\\Type\\Price\\Interceptor->getFinalPrice() called at [vendor\/magento\/module-catalog\/Model\/Product.php:1240]\n#21 Magento\\Catalog\\Model\\Product->getFinalPrice() called at [generated\/code\/Magento\/Catalog\/Model\/Product\/Interceptor.php:419]\n#22 Magento\\Catalog\\Model\\Product\\Interceptor->getFinalPrice() called at [vendor\/magento\/module-quote\/Model\/Quote\/Address\/Total\/Subtotal.php:114]\n#23 Magento\\Quote\\Model\\Quote\\Address\\Total\\Subtotal->_initItem() called at [vendor\/magento\/module-quote\/Model\/Quote\/Address\/Total\/Subtotal.php:55]\n#24 Magento\\Quote\\Model\\Quote\\Address\\Total\\Subtotal->collect() called at [vendor\/magento\/module-quote\/Model\/Quote\/TotalsCollector.php:261]\n#25 Magento\\Quote\\Model\\Quote\\TotalsCollector->collectAddressTotals() called at [generated\/code\/Magento\/Quote\/Model\/Quote\/TotalsCollector\/Interceptor.php:41]\n#26 Magento\\Quote\\Model\\Quote\\TotalsCollector\\Interceptor->collectAddressTotals() called at [vendor\/magento\/module-quote\/Model\/Quote\/TotalsCollector.php:156]\n#27 Magento\\Quote\\Model\\Quote\\TotalsCollector->collect() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#28 Magento\\Quote\\Model\\Quote\\TotalsCollector\\Interceptor->___callParent() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#29 Magento\\Quote\\Model\\Quote\\TotalsCollector\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#30 Magento\\Quote\\Model\\Quote\\TotalsCollector\\Interceptor->___callPlugins() called at [generated\/code\/Magento\/Quote\/Model\/Quote\/TotalsCollector\/Interceptor.php:32]\n#31 Magento\\Quote\\Model\\Quote\\TotalsCollector\\Interceptor->collect() called at [vendor\/magento\/module-quote\/Model\/Quote.php:2016]\n#32 Magento\\Quote\\Model\\Quote->collectTotals() called at [generated\/code\/Magento\/Quote\/Model\/Quote\/Interceptor.php:743]\n#33 Magento\\Quote\\Model\\Quote\\Interceptor->collectTotals() called at [vendor\/magento\/module-checkout\/Model\/Cart.php:592]\n#34 Magento\\Checkout\\Model\\Cart->save() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#35 Magento\\Checkout\\Model\\Cart\\Interceptor->___callParent() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#36 Magento\\Checkout\\Model\\Cart\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#37 Magento\\Checkout\\Model\\Cart\\Interceptor->___callPlugins() called at [generated\/code\/Magento\/Checkout\/Model\/Cart\/Interceptor.php:131]\n#38 Magento\\Checkout\\Model\\Cart\\Interceptor->save() called at [app\/code\/Alius\/ConfigTool\/Observer\/ToCart.php:97]\n#39 Alius\\ConfigTool\\Observer\\ToCart->execute() called at [vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php:88]\n#40 Magento\\Framework\\Event\\Invoker\\InvokerDefault->_callObserverMethod() called at [vendor\/magento\/framework\/Event\/Invoker\/InvokerDefault.php:74]\n#41 Magento\\Framework\\Event\\Invoker\\InvokerDefault->dispatch() called at [vendor\/magento\/framework\/Event\/Manager.php:65]\n#42 Magento\\Framework\\Event\\Manager->dispatch() called at [generated\/code\/Magento\/Framework\/Event\/Manager\/Proxy.php:95]\n#43 Magento\\Framework\\Event\\Manager\\Proxy->dispatch() called at [vendor\/magento\/framework\/App\/FrontController.php:271]\n#44 Magento\\Framework\\App\\FrontController->dispatchPreDispatchEvents() called at [vendor\/magento\/framework\/App\/FrontController.php:211]\n#45 Magento\\Framework\\App\\FrontController->processRequest() called at [vendor\/magento\/framework\/App\/FrontController.php:147]\n#46 Magento\\Framework\\App\\FrontController->dispatch() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#47 Magento\\Framework\\App\\FrontController\\Interceptor->___callParent() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#48 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/module-store\/App\/FrontController\/Plugin\/RequestPreprocessor.php:99]\n#49 Magento\\Store\\App\\FrontController\\Plugin\\RequestPreprocessor->aroundDispatch() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:135]\n#50 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/module-page-cache\/Model\/App\/FrontController\/BuiltinPlugin.php:71]\n#51 Magento\\PageCache\\Model\\App\\FrontController\\BuiltinPlugin->aroundDispatch() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:135]\n#52 Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#53 Magento\\Framework\\App\\FrontController\\Interceptor->___callPlugins() called at [generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php:23]\n#54 Magento\\Framework\\App\\FrontController\\Interceptor->dispatch() called at [vendor\/magento\/framework\/App\/Http.php:116]\n#55 Magento\\Framework\\App\\Http->launch() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:58]\n#56 Magento\\Framework\\App\\Http\\Interceptor->___callParent() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:138]\n#57 Magento\\Framework\\App\\Http\\Interceptor->Magento\\Framework\\Interception\\{closure}() called at [vendor\/magento\/framework\/Interception\/Interceptor.php:153]\n#58 Magento\\Framework\\App\\Http\\Interceptor->___callPlugins() called at [generated\/code\/Magento\/Framework\/App\/Http\/Interceptor.php:23]\n#59 Magento\\Framework\\App\\Http\\Interceptor->launch() called at [vendor\/magento\/framework\/App\/Bootstrap.php:264]\n#60 Magento\\Framework\\App\\Bootstrap->run() called at [pub\/index.php:30]\n","url":"\/configtool\/project\/tocart","script_name":"\/index.php","report_id":"20905d1f00299ac89012742554e0e08e5bac10598642c6fc0814944dbcf7c81c"}

gerrits-ecommerce commented 1 year ago

For a temporary fix we added changed the build() function to:

public function build(array $priceInfo, $productId): array
{
    return [
        'pricePerUOM' => $this->getPricePerUom($priceInfo, $productId),
        'UOM' => $priceInfo['uoM'] ?? ''
    ];
}

in file: vendor/commerce365/module-customer-price/Service/Additional/AdditionalDataBuilder.php Line: 19

hostep commented 1 year ago

@TysvdHeuvel: It looks like version 1.1.1 wasn't pushed to packagist, can that be? https://packagist.org/packages/commerce365/module-customer-price

Most likely because the version number wasn't updated in the composer.json file. I would recommend to completely remove version numbers from the composer.json file and let packagist deal with the tagged versions in the git repo, that's easier and won't lead to such mistakes in the future anymore.