magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.5k stars 9.31k forks source link

Call to a member function getTypeId() on bool #37626

Closed sannam-wesco closed 1 year ago

sannam-wesco commented 1 year ago

Preconditions and environment

Steps to reproduce

  1. Requisition Lists, addProductsToRequisitionList → Add a valid SKU that is not isVisibleInCatalog
  2. What is happening: a. \Magento\RequisitionList\Model\RequisitionListProduct::getProduct will return false b. \Magento\GroupedRequisitionList\Plugin\Model\RequisitionListItem\SaveHandler::aroundSaveItem will try to access the product getTypeId property. But since product is false, the process crashes.

Expected result

  1. it should not report as an error back in response "report.ERROR: Call to a member function getTypeId()".

Actual result

  1. Getting error as "report.ERROR: Call to a member function getTypeId() on bool"

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @sannam-wesco. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 1 year ago

Hi @engcom-Bravo. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

Adward345 commented 1 year ago

The error message "Call to a member function getTypeId() on boo" typically indicates that you are trying to invoke the getTypeId() method on a variable or object that is not of the expected type or does not have that method defined.

The error message suggests that the variable or object in question is of type "boo" instead of the expected type. It's important to ensure that you are working with the correct object or variable and that it has the necessary methods defined.

To troubleshoot this issue, you can follow these steps:

Check the variable or object: Verify the variable or object you are trying to invoke the getTypeId() method on. Make sure it is the correct object and that it is instantiated properly.

Review the object's definition: Examine the class or object definition to ensure that the getTypeId() method is actually defined within that class. Check for any typos through viptools-apk or incorrect method names.

engcom-Bravo commented 1 year ago

@Adward345 Thanks for your contribution & collaboration over here.

Hi @sannam-wesco,

Thank you for reporting and collaboration.

Verified the issue on Magento 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

We have created a product with visibility as Not Visible Individually

Screenshot 2023-06-21 at 3 29 35 PM

We are not getting any error in the response.

Screenshot 2023-06-21 at 3 26 46 PM

Kindly recheck the behaviour on Magento 2.4-develop instance with EE edition and elaborate steps to reproduce if the issue is still reproducible.

Thanks.

sannam-wesco commented 1 year ago

@engcom-Bravo

Issue is still exist.

Steps to reproduce

  1. in Magento Admin side. go to products -> Edit any product and disable the product. to make it inVisibleInCatalog to No
  2. Go to postman and try to add that product to requisition list.
  3. it is throwing the error

Expected behaviour:

  1. it should not throw an error. and should display message somthing like "The SKU was not found."

I checked in Magento EE Eidtion.

The culprit is in "vendor\magento\module-requisition-list\Model\RequisitionListProduct.php" file in getProduct($sku) function is returning false, if product is not visible in catalog. But in "vendor\magento\module-grouped-requisition-list\Plugin\Model\RequisitionListItem\SaveHandler.php" $parentProduct = $this->requisitionListProduct->getProduct((string)$productData->getSku()); if ($parentProduct->getTypeId() !== Grouped::TYPE_CODE) // This line trying to get Type Id on false.

image

engcom-Bravo commented 1 year ago

Hi @sannam-wesco,

Thanks for your update.

Verified the issue on Magento 2.4-develop instance with ee edition and the issue is not reproducible.Kindly refer the screenshots.

Steps to reproduce

We have disabled the product Simple.

Screenshot 2023-06-22 at 12 55 06 PM

We are getting as The SKU was not found.

Screenshot 2023-06-22 at 12 54 57 PM

Kindly recheck the behaviour on Magento 2.4-develop instance with EE edition and elaborate steps to reproduce if the issue is still reproducible.

Thanks.

engcom-Bravo commented 1 year ago

Hi @sannam-wesco,

We have noticed that this issue has not been updated since long time.
Hence we assume that this issue is fixed now, so we are closing it. Please feel to raise a fresh ticket or reopen this ticket if you need more assistance on this.

Thanks.