cakephp 3.x Saving Nested (deep) Association

試著忘記壹切 提交于 2019-12-01 18:28:40

The product_sku_attributes data is not being marshalled, it's still an array of arrays, and not an array of entities, hence it's not being saved.

Just like when saving entities, creating/patching them with associated data by default only works for first level associations. Deeper nested associations require to specify them via the associated option, ie:

$entity = $products->newEntity($product_data[0], [
    'associated' => [
        'ProductSkus.ProductSkuAttributes'
    ]
]);

$products->save($entity, [
    'associated' => [
        'ProductSkus.ProductSkuAttributes'
    ]
]);

See also

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!