1

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.

Greetings!

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

1 Answer 1

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
  • 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 that you have read and understand our privacy policy and code of conduct.

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