public function afterAddProduct(
        Quote $subject,
        $result
    ) {
        try {
            if ($result instanceof \Magento\Quote\Model\Quote\Item) {
                /** @var \Magento\Quote\Model\Quote\Item $result */
                $product = $result->getProduct();
                if ($product !== null) {
                    $this->logEvent($product->getId(), $product->getStoreId());
                }
            }
        } catch (\Exception $e) {
            $this->logger->error($e->getMessage(), []);
        }

        return $result;
    }
public function afterAddProduct(
        Quote $subject,
        $result
    ) {
        try {
            if ($result instanceof \Magento\Quote\Model\Quote\Item) {
                /** @var \Magento\Quote\Model\Quote\Item $result */
                $product = $result->getProduct();
                if ($product !== null) {
                    $this->logEvent($product->getId(), $product->getStoreId());
                }
            }
        } catch (\Exception $e) {
            $this->logger->error($e->getMessage(), []);
        }

        return $result;
    }
public function afterAddProduct ( Quote $ subject , $ result ) { try { if ( $ result instanceof \ Magento \ Quote \ Model \ Quote \ Item ) { /** @var \Magento\Quote\Model\Quote\Item $result */ $ product = $ result -> getProduct ( ) ; if ( $ product !== null ) { $ this -> logEvent ( $ product -> getId ( ) , $ product -> getStoreId ( ) ) ; } } } catch ( \ Exception $ e ) { $ this -> logger -> error ( $ e -> getMessage ( ) , [ ] ) ; } return $ result ; }
Log add to cart events into the event queue.

@SuppressWarnings(PHPMD.UnusedFormalParameter)

@param Quote                           $subject Quote.
@param \Magento\Quote\Model\Quote\Item $result  Quote Item.

@return \Magento\Quote\Model\Quote\Item|string
Log add to cart events into the event queue .