associations saving many to many workign now catalogs
This commit is contained in:
@@ -71,7 +71,8 @@ class ExternalProductCatalogsController extends AppController
|
||||
],
|
||||
];
|
||||
$postData = $this->request->getData();
|
||||
|
||||
Log::debug(print_r('$postData', true));
|
||||
Log::debug(print_r($postData, true));
|
||||
$externalProductCatalog = $this->ExternalProductCatalogs->patchEntity($externalProductCatalog, $postData, $saveOptions);
|
||||
if ($this->ExternalProductCatalogs->save($externalProductCatalog, $saveOptions)) {
|
||||
$this->Flash->success(__('The external product catalog has been saved.'));
|
||||
|
||||
@@ -3,6 +3,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Entity;
|
||||
|
||||
use Cake\I18n\DateTime;
|
||||
use Cake\ORM\Entity;
|
||||
|
||||
/**
|
||||
@@ -11,10 +12,11 @@ use Cake\ORM\Entity;
|
||||
* @property int $id
|
||||
* @property string $base_url
|
||||
* @property string $api_url
|
||||
* @property \Cake\I18n\DateTime $created
|
||||
* @property \Cake\I18n\DateTime|null $deleted
|
||||
* @property DateTime $created
|
||||
* @property DateTime|null $deleted
|
||||
*
|
||||
* @property \CakeProducts\Model\Entity\ProductCatalog[] $product_catalogs
|
||||
* @property ProductCatalog[] $product_catalogs
|
||||
* @property ExternalProductCatalogsProductCatalog[] $external_product_catalogs_product_catalogs
|
||||
*/
|
||||
class ExternalProductCatalog extends Entity
|
||||
{
|
||||
@@ -33,6 +35,6 @@ class ExternalProductCatalog extends Entity
|
||||
'created' => true,
|
||||
'deleted' => true,
|
||||
'enabled' => true,
|
||||
'product_catalogs' => true,
|
||||
'external_product_catalogs_product_catalogs' => true,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace CakeProducts\Model\Table;
|
||||
|
||||
use ArrayObject;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Datasource\EntityInterface;
|
||||
use Cake\Datasource\ResultSetInterface;
|
||||
use Cake\Event\EventInterface;
|
||||
use Cake\ORM\Association\BelongsTo;
|
||||
use Cake\ORM\Behavior\TimestampBehavior;
|
||||
use Cake\ORM\Query\SelectQuery;
|
||||
@@ -55,6 +58,9 @@ class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
|
||||
$this->addBehavior('Timestamp');
|
||||
|
||||
$this->setEntityClass(
|
||||
Configure::read('CakeProducts.ExternalProductCatalogsProductCatalogs.entity', 'CakeProducts\Model\Entity\ExternalProductCatalogsProductCatalog')
|
||||
);
|
||||
$this->belongsTo('ExternalProductCatalogs', [
|
||||
'className' => 'CakeProducts.ExternalProductCatalogs',
|
||||
// 'foreignKey' => 'external_product_catalog_id',
|
||||
@@ -84,13 +90,18 @@ class ExternalProductCatalogsProductCatalogsTable extends Table
|
||||
->notEmptyString('product_catalog_id');
|
||||
|
||||
$validator
|
||||
->boolean('enabled')
|
||||
->requirePresence('enabled', 'create')
|
||||
->notEmptyString('enabled');
|
||||
->boolean('enabled');
|
||||
|
||||
return $validator;
|
||||
}
|
||||
|
||||
public function beforeMarshal(EventInterface $event, ArrayObject $data, ArrayObject $options)
|
||||
{
|
||||
if (!isset($data['enabled'])) {
|
||||
$data['enabled'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rules checker object that will be used for validating
|
||||
* application integrity.
|
||||
|
||||
Reference in New Issue
Block a user