| Conditions | 4 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function up(Schema $schema) |
||
| 19 | { |
||
| 20 | $app = Application::getInstance(); |
||
| 21 | $repository = $app['orm.em']->getRepository('Eccube\Entity\Master\ProductListOrderBy'); |
||
| 22 | |||
| 23 | // 価格が高い順ソートの追加 |
||
| 24 | $ProductListOrderBy = $repository->find(3); |
||
| 25 | if (is_null($ProductListOrderBy)) { |
||
| 26 | $rank = $repository->createQueryBuilder('pl') |
||
| 27 | ->select('MAX(pl.rank)') |
||
| 28 | ->getQuery() |
||
| 29 | ->getSingleScalarResult(); |
||
| 30 | $ProductListOrderBy = new ProductListOrderBy(); |
||
| 31 | $ProductListOrderBy->setId(3); |
||
| 32 | $ProductListOrderBy->setName('価格が高い順'); |
||
| 33 | $ProductListOrderBy->setRank($rank + 1); |
||
| 34 | $app['orm.em']->persist($ProductListOrderBy); |
||
| 35 | $app['orm.em']->flush($ProductListOrderBy); |
||
| 36 | } |
||
| 37 | |||
| 38 | // "価格順"の名称を"価格が低い順"へ変更 |
||
| 39 | $ProductListOrderBy = $repository->find(1); |
||
| 40 | if (!is_null($ProductListOrderBy) && $ProductListOrderBy->getName() === '価格順') { |
||
| 41 | $ProductListOrderBy->setName('価格が低い順'); |
||
| 42 | $app['orm.em']->persist($ProductListOrderBy); |
||
| 43 | $app['orm.em']->flush($ProductListOrderBy); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 56 |