Skip to content

Commit 78af5b8

Browse files
author
Danilo Argentiero
committed
Get review entity id by code instead hard-coded.
1 parent 5177344 commit 78af5b8

File tree

1 file changed

+2
-1
lines changed
  • app/code/Magento/Review/Controller/Adminhtml/Product

1 file changed

+2
-1
lines changed

app/code/Magento/Review/Controller/Adminhtml/Product/Post.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\Controller\ResultFactory;
1111
use Magento\Store\Model\Store;
1212
use Magento\Framework\Exception\LocalizedException;
13+
use Magento\Review\Model\Review;
1314

1415
class Post extends ProductController implements HttpPostActionInterface
1516
{
@@ -33,7 +34,7 @@ public function execute()
3334
}
3435
$review = $this->reviewFactory->create()->setData($data);
3536
try {
36-
$review->setEntityId(1) // product
37+
$review->setEntityId($review->getEntityIdByCode(Review::ENTITY_PRODUCT_CODE))
3738
->setEntityPkValue($productId)
3839
->setStoreId(Store::DEFAULT_STORE_ID)
3940
->setStatusId($data['status_id'])

0 commit comments

Comments
 (0)