Friday, September 4, 2020

Sitecore Experience Commerce ( Fix for AddCartLine: Value cannot be null )

 


Recently, I got below error while adding an item into the cart -

Sitecore XP and XC Version 9.3 

 {"Lines":null,"Email":null,"Subtotal":null,"TaxTotal":null,"Total":null,
"ShippingTotal":null,"TotalAmount":0,"Shipments":null,"Payments":null,"Parties"
:null,"AccountingParty":null,"Discount":null,"PromoCodes":null,  


Investigation steps -
  1. Initially, I thought this could be related to data, so I refreshed the cache, updated the XC template and did the reindex.
  2. I verified data exits in the Solr index.
  3. Found one issue in xConnect related to model - When I browse the xConnect found model is a not correct issue, and that got fix when I updated the right model.
  4. I did the bootstrap and item sync path 
  5. I did add to cart through the postman, and it worked perfectly fine. you need to pass below details
 {  
   "cartId":"Cart01",  
   "itemId": "XXX |AW098 04|5",  
   "quantity": 1  
 }  
The issue still exists after performing all above 5 points. Finally, I have redeployed complete XP and XC website and did all steps again like commerce refresh cache, bootstrap and indexing. That also didn't resolve the issue.


 Fix - FInally, I had to restore all three databases - Master, XCGlobal and XCShared and that help us to see the add to cart functionality again.

but still, what was the issue? - After further investigation, I came to know that during the catalog import process we got below errors -

 Entity-SellableItem-7042259#Entity-SellableItem-demohandtowel1#Entity-SellableItem-demoitem1#Entity-SellableItem-DN136182#Entity-SellableItem-DN136185#Entity-SellableItem-DN136186#Entity-SellableItem-DN136188#Entity-SellableItem-DN136200#Entity-SellableItem-DN136201#Entity-SellableItem-DN136204#Entity-SellableItem-DN136207#Entity-SellableItem-DN136210#Entity-SellableItem-DN139713#Entity-SellableItem-DN139715#Entity-SellableItem-DN139716#Entity-SellableItem-DN142257#Entity-SellableItem-DN151084#Entity-SellableItem-DN142603#Entity-SellableItem-DN142604#Entity-SellableItem-DN142608#Entity-SellableItem-DN142609#Entity-SellableItem-DN151084#Entity-SellableItem-DN151248#Entity-SellableItem-DN151249#Entity-SellableItem-DN151250#Entity-SellableItem-DN151254#Entity-SellableItem-DN162370#Entity-SellableItem-DN162371#Entity-SellableItem-DN162373#Entity-SellableItem-DN162374#Entity-SellableItem-DN162375#Entity-SellableItem-DNEN96#Entity-SellableItem-eb101#Entity-SellableItem-eb102test#Entity-SellableItem-N151248#Entity-SellableItem-TestProduct123'|Environment='Entity-CommerceEnvironment-XXXXX'|Message=  
 'Violation of PRIMARY KEY constraint 'PK_VersioningEntity'.  
  Cannot insert duplicate key in object 'sitecore_commerce_storage.VersioningEntity'.  
  The duplicate key value is (0604f03b-b6a7-a7c4-72d4-23f95337b340).\r\nDuplicate key was ignored.\r\nDuplicate key was ignored.\r\nDuplicate key was ignored.\r\nThe statement has been terminated.'|Number='2627'|Procedure='sitecore_commerce_storage.InsertEntities'|Line='645']",  
       "CommerceTermKey": "SQL:blocks:AddEntities"  

and that's the issue, we ran the import process, and there was an existing reference, 

Finally, I cleaned the environment and reimported it again, and that had resolved the issue entirely.

No comments:

Post a Comment