LoginSignup
2
1

More than 5 years have passed since last update.

twigだけで特定のProductデータ取得を行う

Posted at

概要

PHP側でデータ取得を行わず、twigのみでProductデータを取得する方法を説明します。
(デザイナーさんなど、テンプレートのみ編集される方に便利な機能です。)

使い方

  • 非公開データを含む取得の場合
    {% set Product = app['eccube.repository.product'].find(1) %}
  • 非公開データを除く場合
    {% set Product = app['eccube.repository.product'].get(1) %}

補足

上記だとデータが取得できない場合、システムエラーになります。
システムエラーを回避するための、関数の提供が以下PullRequestで上がっているので、
時期バージョンに期待しましょう。
https://github.com/EC-CUBE/ec-cube/pull/2305

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1