Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Repository/ProductReviewRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public function __construct(RegistryInterface $registry)
public function getQueryBuilderBySearchData($searchData)
{
$qb = $this->createQueryBuilder('r')
->select('r, p, pc')
->select('r, p, pc, c')
->innerJoin('r.Product', 'p')
->innerJoin('r.Customer', 'c')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
->innerJoin('r.Customer', 'c')
->leftJoin('r.Customer', 'c')

ログインしないでレビューを投稿するとCustomerがnullになります。
�innerJoinでは会員が紐づいていないレビューが取得できなくなるかと思います。

->innerJoin('p.ProductClasses', 'pc');

// 投稿者名・投稿者URL
Expand Down
5 changes: 4 additions & 1 deletion Resource/template/admin/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@
<tr>
<td class="text-center">{{ Review.id }}</td>
<td>{{ Review.create_date|date_min }}</td>
<td>{{ Review.reviewer_name }}</td>
<td>
{{ Review.reviewer_name }}<br>
<a href="{{ url('admin_customer_edit', { 'id': Review.Customer.id}) }}">{{ Review.Customer.name01 }}&nbsp;{{ Review.Customer.name02 }}</a><br>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<a href="{{ url('admin_customer_edit', { 'id': Review.Customer.id}) }}">{{ Review.Customer.name01 }}&nbsp;{{ Review.Customer.name02 }}</a><br>
{% if Review.Customer %}
<a href="{{ url('admin_customer_edit', { 'id': Review.Customer.id}) }}">{{ Review.Customer.name01 }}&nbsp;{{ Review.Customer.name02 }}</a>
{% endif %}

Customerが存在しないレビューでエラーとなるので条件分岐がいるかと思います。

</td>
<td>{{ Review.Product.name }}</td>
<td>
<a href="{{ url('product_review_admin_product_review_edit', { id : Review.id }) }}">{{ Review.title }}</a>
Expand Down