wip
This commit is contained in:
@@ -96,8 +96,25 @@ class ProductSkusController extends AppController
|
||||
if ($this->request->is('post')) {
|
||||
$postedSkus = $this->request->getData();
|
||||
$saveOptions = [
|
||||
'fields' => [
|
||||
'product_id',
|
||||
'sku',
|
||||
'barcode',
|
||||
'price',
|
||||
'cost',
|
||||
'product_sku_variant_values',
|
||||
'created',
|
||||
'modified',
|
||||
'enabled',
|
||||
],
|
||||
'associated' => [
|
||||
'ProductSkuVariantValues',
|
||||
'ProductSkuVariantValues' => [
|
||||
'validate' => false,
|
||||
'fields' => [
|
||||
'product_category_variant_id',
|
||||
'product_category_variant_option_id',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
$finalPostData = [];
|
||||
@@ -117,11 +134,12 @@ class ProductSkusController extends AppController
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$productSkus = $table->patchEntities($productSkus, $finalPostData, $saveOptions);
|
||||
$errors = [];
|
||||
$successes = [];
|
||||
foreach ($productSkus as $productSkuToSave) {
|
||||
// dd($productSkuToSave);
|
||||
|
||||
if (!$table->save($productSkuToSave, $saveOptions)) {
|
||||
Log::debug(print_r('$productSkuToSave->getErrors()', true));
|
||||
Log::debug(print_r($productSkuToSave->getErrors(), true));
|
||||
|
||||
@@ -45,6 +45,6 @@ class ProductSku extends Entity
|
||||
|
||||
// entities
|
||||
'product' => false,
|
||||
'product_sku_variant_values' => false,
|
||||
'product_sku_variant_values' => true,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -101,8 +101,10 @@ class ProductSkuVariantValuesTable extends Table
|
||||
public function buildRules(RulesChecker $rules): RulesChecker
|
||||
{
|
||||
$rules->add($rules->existsIn(['product_sku_id'], 'ProductSkus'), ['errorField' => 'product_sku_id']);
|
||||
$rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']);
|
||||
$rules->add($rules->existsIn(['product_category_variant_option_id'], 'ProductCategoryVariantOptions'), ['errorField' => 'product_category_variant_option_id']);
|
||||
|
||||
// @TODO why not working?? causing tests to fail / associated variant values not saving on product-skus/add
|
||||
// $rules->add($rules->existsIn(['product_category_variant_id'], 'ProductCategoryVariants'), ['errorField' => 'product_category_variant_id']);
|
||||
// $rules->add($rules->existsIn(['product_category_variant_option_id'], 'ProductCategoryVariantOptions'), ['errorField' => 'product_category_variant_option_id']);
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user