Sorting hasOne Relationship


#1

Hi,
I am trying to get working hasOne association with sorting in my model but without luck.

My Products model:

 $this->hasMany('ProductMedias', [
        'foreignKey' => 'product_id',
        'className' => 'Products.ProductMedias'
 ]);

$this->hasOne('ProductFirstMedias', [
          'className' => 'Products.ProductMedias',
          'foreignKey' => 'product_id',
          'strategy' => 'select',
          'sort' => [
		'ProductFirstMedias.position' => 'ASC',
		'ProductFirstMedias.created' => 'ASC',
        ]
]);

I
Possible keys for hasOne association arrays does not include sort keys in cakephp3 documentation. How to sort hasOne Model ?


#2

Ok. I found solution: