not used to plugin testing - trying to get working but fixtures not working yet
This commit is contained in:
@@ -10,6 +10,7 @@ use Cake\Log\Log;
|
||||
use Cake\ORM\Locator\LocatorAwareTrait;
|
||||
use Cake\ORM\Table;
|
||||
use Cake\Utility\Text;
|
||||
use CakeProducts\Model\Entity\ExternalProductCatalog;
|
||||
use CakeProducts\Model\Entity\ProductCategory;
|
||||
use CakeProducts\Model\Table\ProductCatalogsTable;
|
||||
|
||||
@@ -55,6 +56,40 @@ class InternalCatalogManagerService
|
||||
return $this->ProductCatalogs->get($id, contain: $contain);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExternalProductCatalog $externalProductCatalog external product catalog entity
|
||||
* @param array $data data to save
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createNewExternalCatalog(ExternalProductCatalog $externalProductCatalog, array $data = []): array
|
||||
{
|
||||
$now = Time::now();
|
||||
$associated = [];
|
||||
|
||||
Log::info('posted data - adding new ExternalProductCatalog');
|
||||
Log::info(print_r($data, true));
|
||||
|
||||
$saveOptions = [
|
||||
'associated' => $associated,
|
||||
];
|
||||
$externalProductCatalog = $this->ProductCatalogs->ExternalProductCatalogs->patchEntity($externalProductCatalog, $data, $saveOptions);
|
||||
if ($externalProductCatalog->getErrors()) {
|
||||
Log::debug(print_r('$externalProductCatalog->getErrors() next - failed to save from create new external product catalog', true));
|
||||
Log::debug(print_r($externalProductCatalog->getErrors(), true));
|
||||
}
|
||||
$returnData = [
|
||||
'entity' => $externalProductCatalog,
|
||||
'result' => $this->ProductCatalogs->ExternalProductCatalogs->save($externalProductCatalog, $saveOptions),
|
||||
'apiResults' => [],
|
||||
];
|
||||
if ($returnData['result'] && $this->externalCatalogManager) {
|
||||
// $returnData['apiResults'] = $this->externalCatalogManager->newCatalogCreated($returnData['result']);
|
||||
}
|
||||
|
||||
return $returnData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $id
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user