-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathProductReviewSummary.php
More file actions
69 lines (63 loc) · 2.46 KB
/
ProductReviewSummary.php
File metadata and controls
69 lines (63 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
ini_set('display_startup_errors', 1);ini_set('display_errors', 1); error_reporting(-1);
//// Setup Base
$folder = 'magento2'; //Folder Name
$file = $folder ? dirname(__FILE__) . "/$folder/app/bootstrap.php" : "app/bootstrap.php";
$file = str_replace('.com/', '.coms/', $file);
$file = str_replace('/public_html/', '/magento2/', $file);
if(!file_exists ($file)) $file = "app/bootstrap.php";
if(file_exists ($file)){
require $file;
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
} else {die('Not found bootstrap.php');}
class reviewProduct extends \Magento\Framework\App\Http
implements \Magento\Framework\AppInterface {
public function launch()
{
$this->getReviewCollection();
//the method must end with this line
return $this->_response;
}
public function getReviewCollection()
{
$collections = $this->_objectManager->create('\Magento\Review\Model\ResourceModel\Review\Summary\Collection');
$reviewSummary = $collections->addFieldToSelect('entity_pk_value')
->setOrder('rating_summary', 'DESC')
// ->setOrder('reviews_count', 'DESC')
->setPageSize(10) // only get 10 reviews
->setCurPage(1);
// $reviewProduct = $reviewProduct->getSelect()->group('entity_pk_value');
$reviewSummary->distinct(true);
$productIds = [];
foreach ($reviewSummary as $review){
$productIds[] = $review->getData('entity_pk_value');
}
var_dump($productIds);
?>
<table>
<thead align="left" style="display: table-header-group">
<tr>
<th>review_id</th>
<th>entity_pk_value(Product ID)</th>
<th>title</th>
<th>detail</th>
<th>nickname</th>
<th>customer_id</th>
</tr>
</thead>
<tbody>
<?php foreach ($reviewSummary as $review) : ?>
<?php
echo '<pre>';
var_dump($review->toArray());
echo '</pre>';
?>
<?php endforeach; ?>
</tbody>
</table>
<?php
}
}
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication('reviewProduct');
$bootstrap->run($app);