Insert or update a product.

All the $productdata array fields have filters associated with the values. The filters have the prefix 'pre.' followed by the field name. An example using 'product_status' would have the filter called, 'pre.product.status' that can be hooked into.


  • Full name: cms_insert_product
  • Defined in: cms/core/Shared/Helpers/product.php

Parameters

Parameter Type Description
$productdata array|\Psr\Http\Message\ServerRequestInterface|\App\Domain\Product\Model\Product An array of data that is used for insert or update.

@type string $title The product's title. @type string $body The product's body. @type string $slug The product's slug. @type string $author The product's author. @type string $sku The product's parent. @type string $price The product's price. @type string $currency The product's currency. @type string $purchaseUrl The product's purchase url. @type string $showInMenu Whether to show product in menu. @type string $showInSearch Whether to show product in search. @type string $relativeUrl The product's relative url. @type string $featuredImage THe product's featured image. @type string $status THe product's status. @type string $published Timestamp describing the moment when the product was published. Defaults to Y-m-d h:i A. |

Return Value

\Qubus\Error\Error|string|null

The newly created product's product_id or throws an error or returns null if the product could not be created or updated.