please help, I'm struggling with this.

I'm using this plugin

public function afterAddProduct($subject, $productInfo, $requestInfo = null)

I'm trying to get the product Id of the product in this way:

$productId = $subject->getId();

$productId = $productInfot->getId();

none of this works, i'm getting nothing, when I print with echo I get this:

Product ID:  

I'm struggling a lot with this, I could get the product ID with beforeAddProduct in this way, but I must use afterAddProduct because is the only plugin that fits my solution.


  • Hi, I need to check your code. May 14, 2020 at 4:53

1 Answer 1


In afterAddProduct(), you can get the product Id with $requestInfo param. Below is the example code for getting product Id in afterAddProduct().

public function afterAddProduct($subject, $productInfo, $requestInfo = null)
    $productId = $requestInfo->getEntityId();

Hope it helps!!!

  • 1
    Thanks! it works perfectly! May 14, 2020 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.