EC-CUBE3.0.15
商品情報追加プラグインで追加した値を元に商品一覧をソートすることは可能でしょうか?
商品情報に「公開日」という項目を追加し、商品一覧ページ表示時にこの値を元にソートしたいと考えています。
以下のように実装してみたのですが、エラーが発生してしまいます。
どうすればエラーを解決できますでしょうか?または他に良い方法がありますでしょうか?
■エラー
ContextErrorException in SqlWalker.php line 887:
Notice: Undefined index: Product
src/Eccube/Resource/doctrine/Eccube.Entity.Product.dcm.yml
ManyToOne:
PlgExpandProductColumnsValue:
targetEntity: Plugin\PlgExpandProductColumns\Entity\PlgExpandProductColumnsValue
mappedBy: Product
src/Eccube/Entity/Product.php
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $PlgExpandProductColumnsValue;
/**
* Add PlgExpandProductColumnsValue
*
* @param \Plugin\PlgExpandProductColumns\Entity\PlgExpandProductColumnsValue $plgExpandProductColumnsValue
* @return Product
*/
public function addPlgExpandProductColumnsValue(\Plugin\PlgExpandProductColumns\Entity\PlgExpandProductColumnsValue $plgExpandProductColumnsValue)
{
$this->PlgExpandProductColumnsValue[] = $plgExpandProductColumnsValue;
return $this;
}
/**
* Remove PlgExpandProductColumnsValue
*
* @param \Plugin\PlgExpandProductColumns\Entity\PlgExpandProductColumnsValue $plgExpandProductColumnsValue
*/
public function removePlgExpandProductColumnsValue(\Plugin\PlgExpandProductColumns\Entity\PlgExpandProductColumnsValue $plgExpandProductColumnsValue)
{
$this->PlgExpandProductColumnsValue->removeElement($plgExpandProductColumnsValue);
}
/**
* Get PlgExpandProductColumnsValue
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPlgExpandProductColumnsValue()
{
return $this->PlgExpandProductColumnsValue;
}
src/Eccube/Repository/ProductRepository.php
$qb->leftJoin('p.PlgExpandProductColumnsValue', 'pepcv', 'WITH', 'pepcv.columnId = 16'); // 公開日
$qb->orderBy('pepcv.value', 'DESC');