lsretailomni / lsmag-two

LS Ecommerce - Magento, an ecommerce interface for integrating Magento with LS Central.
https://www.lsretail.com/
10 stars 16 forks source link

PointResult formatted to string gives errors #58

Closed xcom-magento closed 2 months ago

xcom-magento commented 3 months ago

In the latest master branch there is an issue where points are converted to string that throws errors. In vendor/lsretail/lsmag-two/src/Omni/Helper/LoyaltyHelper.php the formatValue method is changed to use the currencyHelper. This value is used in multiple requests and this is causing issues. For example the OneListCalculate endpoint doesn't work so the product price is 0.

Preconditions (*)

  1. Magento version: 2.4.7
  2. LS Ecommerce Magento version: latest master commit
  3. LS Commerce version: 2024.4.1
  4. LS Central version: 22.0.19.1004556 (23.1.16.587 [17599])
  5. LS Retail partner: TCOG

Steps to reproduce (*)

  1. Add a product to the cart
  2. Check OneListCalculate response in omniclient.log file

Expected result (*)

  1. Correct pricing and working cart page

Actual result (*)

Below a request and response from the OneListCalculate

[2024-06-25T11:34:15.547308+00:00] OmniLoggerHandler.DEBUG: ==== REQUEST ==== 06-25-2024 11:34:14.684604 ==== OneListCalculate ==== [] []
[2024-06-25T11:34:15.548428+00:00] OmniLoggerHandler.DEBUG: 
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://lsretail.com/LSOmniService/Base/2017" xmlns:ns2="http://lsretail.com/LSOmniService/Loy/2017" xmlns:ns3="http://lsretail.com/LSOmniService/EComm/2017/Service">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <ns3:OneListCalculate>
      <ns3:oneList>
        ...
        <ns2:CurrencyFactor>1,00</ns2:CurrencyFactor>
        ...

Response:

[2024-06-25T11:34:08.526435+00:00] OmniLoggerHandler.DEBUG: ==== Time Elapsed ==== 0 minute(s) 0.988644 second(s) ==== OneListCalculate ==== [] []
[2024-06-25T11:34:08.526572+00:00] OmniLoggerHandler.DEBUG: 
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <s:Fault>
      <faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode>
      <faultstring xml:lang="nl-NL">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://lsretail.com/LSOmniService/EComm/2017/Service:oneList. The InnerException message was 'There was an error deserializing the object of type LSRetail.Omni.Domain.DataModel.Loyalty.Baskets.OneList. The value '1,00' cannot be parsed as the type 'decimal'.'.  Please see InnerException for more details.</faultstring>
      <detail>
        <ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
          <HelpLink i:nil="true"/>
          <InnerException>
            <HelpLink i:nil="true"/>
            <InnerException>
              <HelpLink i:nil="true"/>
              <InnerException>
                <HelpLink i:nil="true"/>
                <InnerException i:nil="true"/>
                <Message>Input string was not in a correct format.</Message>
                <StackTrace>   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseDecimal(String value, NumberStyles options, NumberFormatInfo numfmt)
   at System.Xml.XmlConverter.ToDecimal(String value)</StackTrace>
                <Type>System.FormatException</Type>
              </InnerException>
              <Message>The value '1,00' cannot be parsed as the type 'decimal'.</Message>
              ...

Also when navigating to the cart the error Warning: A non-numeric value encountered in /vendor/lsretail/lsmag-two/src/Omni/Plugin/Quote/CartTotalRepository.php is thrown.

SyedWaqasNabi commented 3 months ago

Hi @xcom-magento thank you for reporting this issue. In order to reproduce it we want to know which currency are you using? Are you facing this problem on other requests also?

xcom-magento commented 3 months ago

Hi @SyedWaqasNabi, we are using Euro (EUR) as currency. We didn't checked all the functionalities, but in the log file we only see the OneListCalculate endpoint that gives errors.

SyedWaqasNabi commented 2 months ago

Hi @xcom-magento thank you for providing the information. We would like to know what results you get for the GetPointRate call in the logs?

xcom-magento commented 2 months ago

Hi @SyedWaqasNabi, below the request and response for the GetPointRate call:

[2024-06-25T11:34:07.523505+00:00] OmniLoggerHandler.DEBUG: ==== REQUEST ==== 06-25-2024 11:34:05.199442 ==== GetPointRate ==== [] []
[2024-06-25T11:34:07.524736+00:00] OmniLoggerHandler.DEBUG: 
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://lsretail.com/LSOmniService/EComm/2017/Service">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <ns1:GetPointRate>
      <ns1:currency>EUR</ns1:currency>
    </ns1:GetPointRate>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
 [] []
[2024-06-25T11:34:07.525216+00:00] OmniLoggerHandler.DEBUG: ==== RESPONSE ==== 06-25-2024 11:34:07.519918 ==== GetPointRate ==== [] []
[2024-06-25T11:34:07.525438+00:00] OmniLoggerHandler.DEBUG: ==== Time Elapsed ==== 0 minute(s) 2.320476 second(s) ==== GetPointRate ==== [] []
[2024-06-25T11:34:07.525845+00:00] OmniLoggerHandler.DEBUG: 
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
    <GetPointRateResponse xmlns="http://lsretail.com/LSOmniService/EComm/2017/Service">
      <GetPointRateResult>1</GetPointRateResult>
    </GetPointRateResponse>
  </s:Body>
</s:Envelope>
 [] []
SyedWaqasNabi commented 2 months ago

Hi @xcom-magento thank you for providing the request and response for GetPointRate. What locale option is selected in Magento configuration?

xcom-magento commented 2 months ago

Hi @SyedWaqasNabi, the global locale of the webshop is Dutch (Netherlands). We also have two storeviews with a German locale.

SyedWaqasNabi commented 2 months ago

Hi @xcom-magento thank you for the information. We were able to reproduce it and made some fixes. Currently, it's in testing we will let you know once it's in the master branch.

xcom-magento commented 2 months ago

Hi @SyedWaqasNabi, do you have an idea when the changes will be implemented in the master branch?

SyedWaqasNabi commented 2 months ago

Hi @xcom-magento this issue has been fixed and is available in the Master branch. It will also be available in the next release.