onepica / avatax

One Pica Magento extension for sales tax calculation performed by Avatax
http://www.magentocommerce.com/magento-connect/6760.html
29 stars 34 forks source link

Fatal error when simple product of a configurable product is out of stock #280

Open rafashkembi opened 5 years ago

rafashkembi commented 5 years ago

Hello,

I was experience some issues with this module when my configurable products went out out of stock. So i have multiple configurable products on my website and those products have associated products in them. Some customers had products on their cart very long time ago and when they come back those product wend out of stock. When the module was trying to read the product ID-s i got a fatal error.

STEPS TO REPRODUCE: Add configurable product on cart. Go on magento admin and set the stock of the configuration "Simple product" to 0 Return on frontend as a customer.

Since this was a hotfix i had to make a small patch so customers can proceed with their orders.

First i have modified the following function witch is located on this file: app/code/community/OnePica/AvaTax/Model/Service/Abstract/Tools.php

protected function _retrieveProductIdFromQuoteItem($item)
    {
        $productId = $item->getProductId();

        // Added validation
        if ($item->getOptionByCode('simple_product')->getProduct() != NULL) {

            if ($item->getOptionByCode('simple_product')) {
                $productId = $item->getOptionByCode('simple_product')->getProduct()->getId();
            }

            return $productId;

        }
    }

Next i have modified this function witch is located on this file: app/code/community/OnePica/AvaTax/Model/Service/Avatax/Abstract.php

protected function _getTaxClassCodeByProduct($product)
    {

        // Added validation
        if ($product != NULL) {

            $taxClass = $this->_getTaxClassCollection()->getItemById($product->getTaxClassId());
            return $taxClass ? $taxClass->getOpAvataxCode() : '';

        }

    }

The only modification that i did is that i have added a small validation on both functions.

Best Regards,

Rafael Shkembi PATCH_AVALAX-VALIDATION_CE_v1.9.3.4_CE_v1.9.3.4_v1-2018-10-01-04-32-08.sh.zip

marynychsv commented 5 years ago

Dear Rafael Shkembi,

It looks like this issue needs extra communication and additional investigation. Please, open support ticket regarding Magento AvaTax connect via Avalara Support - support@avalara.com. All requests should go through Avalara support and the respective ticket should be opened on Avalara side.

thank you