Hi there,
I encounter this problem suddenly in few weeks before. The system have no extension update.
Most interesting is it only appear in one store view, the other store don't have such issue.
There has been an error processing your request
Notice: Undefined variable: qty in /magento/vendor/amasty/color-swatches-pro/Model/ResourceModel/Inventory.php on line 185
Error log record number: fd1ead955e0746d2b1af2d1c761c7e77a75bdc6e4b809bd45a481635cad73545
Here is the code and line 185 is "return $qty;"
public function getMsiQty($productSku, $websiteCode) { if (is_array($productSku)) { $itemQty = $this->getItemsQty($productSku, $websiteCode); $reservationsQty = $this->getReservationsQty($productSku, $this->getStockId($websiteCode)); foreach ($productSku as $sku) { $qty[$sku] = ($itemQty[$sku] ?? 0) + ($reservationsQty[$sku] ?? 0); } } else { if (!isset($this->qty[$websiteCode][$productSku])) { $this->qty[$websiteCode][$productSku] = $this->getItemQty($productSku, $websiteCode) + $this->getReservationQty($productSku, $this->getStockId($websiteCode)); } $qty = $this->qty[$websiteCode][$productSku]; } return $qty; }
I have no idea why it only happens on Chinese language store view but not English one.
Looking forward to any comments. Thank you.
Regards,
kf
Hi @kf_luk,
Look at your function getMsiQty(), when running into the if round, the variable $qty has not been declared if it does not go to the foreach round then $qty does not exist so when you return $ qty at the end of the function it will display error message as you have seen.
To fix the problem you can declare $qty = 0 at the beginning of the function
public function getMsiQty($productSku, $websiteCode, $qty = 0) { //--------code here--------// return $qty; }
Hope this can help you! Let me know if you need further assistance.
_________
If issue solved, Click Kudos & Accept as Solution.
Hi Marcus
Thanks for your comments.
After upgrade to 2.4.2 and update the extensions. The error gone.
Regards,
kf
Hi @kf_luk,
Great to hear that! If you need further assistance, please let me know.
Hi,
I have the same problem. I'm trying to link a template that I created for abandoned cart with sending emails to whose abandoned the cart but I cant.
I don't know what is happening because, if I use other template works but with this one doesn't.
I tried to do it many times but the problem persist, and this sentece appears: Error de filtrado plantilla: Notice: Undefined variable: _item in /home/marganovas/magento2/app/code/Mageplaza/Smtp/view/frontend/templates/abandonedcart.phtml on line 76
Someone knows what should I do?
Thanks in advance.