0

The product object has the relation to category object.

protected $relations = [
        'category' => ['hasOne', '\Module\Shop\Model\Category', 'cat_id'],
];

https://github.com/ThingEngineer/PHP-MySQLi-Database-Class#objects-mapping

However if i print {{ product.category.name }} , it will print product , not the category object, due to the __call method of php-Mysqlidb.

So twig can't call to lazy load properties ?

DarkBee
  • 16,592
  • 6
  • 46
  • 58
TomSawyer
  • 3,711
  • 6
  • 44
  • 79
  • `Mysqlidb`? Nothing in your code suggests that you are using this old library – Dharman Oct 01 '21 at 18:21
  • @Dharman the code syntax, object has `$relations` , will be lazy execute the subquery, and twig can't access to it phug can – TomSawyer Oct 01 '21 at 19:48
  • See [here](https://twig.symfony.com/doc/3.x/templates.html#variables) which calls `twig` executes. Guess u'll need to check out what calls to the magic method `__call` and create extra hook – DarkBee Oct 02 '21 at 16:37

0 Answers0