Skip to main content

cart

Magento2 - Get Quote Id from hashed graphql ID

In this wiki, we will write the code to get the entity id from hashed id for Magento2 Quote

protected $maskedQuoteIdToQuoteId;
public function __construct(
       \Magento\Quote\Model\MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId
   ) {
       $this->maskedQuoteIdToQuoteId = $maskedQuoteIdToQuoteId;
   }

then you can call execute function


$cartHash = "6zIMBpw1NSixrw8BpUzIMHOvAR9ZopYW";
$cartId = $this->maskedQuoteIdToQuoteId>execute($cartHash);

 

 

 

Magento 2 Delete the not used Cart after upgrade Magento

It's very recommanded to delete unused carts after you finish the upgrade using these queries all customers carts that are not converted to order will be deleted 

 

select * 
FROM `quote_address`
WHERE `customer_address_id` IS NULL AND `firstname` IS NULL AND `lastname` IS NULL and quote_id in (SELECT entity_id FROM `quote` where is_active= 1)

 

select *    from quote where entity_id not in (select quote_id from quote_address)