Active record is empty relatedRecords. Why?

There are 2 models, ProduceInStore and produceHasSupplier. Which are linked.
In ProduceInStore
public function getProduceHasSupplier()
{
 return $this->hasOne(ProduceHasSupplier::className(), ['code' => 'code']);
 }

In ProduceHasSupplier
public function getProduceHasSupplier()
{
 return $this->hasOne(ProduceHasSupplier::className(), ['code' => 'code']);
 }

What they do: create an array of objects AR(ProduceInStore) in the following conditions.
$two = (new ProduceInStore())::find()->select([
'lbk_Produce_has_Supplier.idProduce',
'lbk_Produce_inStore.code',
'lbk_Produce_inStore.idSupplier',
 'SUM(lbk_Produce_inStore.cnt) remains as'])
->innerJoinWith('produceHasSupplier')
 ->where('lbk_Produce_inStore.cnt > 0')
 ->andWhere(['lbk_Produce_has_Supplier.idSupplier' => $access_groups['supplier']])
 ->andWhere(['lbk_Produce_inStore.idSupplier' => $access_groups['supplier']])
 ->andWhere(['lbk_Produce_has_Supplier.idProduce' => [1461127, 820793]])
->groupBy('lbk_Produce_has_Supplier.code')
->orderBy('lbk_Produce_has_Supplier.idProduce')
 ->all();

What to expect: Array with two ProduceInStore each of which will be the object produceHasSupplier attribute(idProduce).
What I get: Object 1461127 contains attributes. 820793 object contains a blank object produceHasSupplier

PS Tried in the condition -'lbk_Produce_has_Supplier.idProduce' to specify only 820793. In this case, produceHasSupplier contains attributes.
Thought that a problem in castles record, but as mentioned above if you specify one specific record, then everything works as it should.
April 19th 20 at 12:04
0 answer

Find more questions by tags Yii