/** * @throws \Craft\Exception * @throws \Craft\HttpException * @throws \Exception */ private function defaultProducts() { $productTypes = \Craft\craft()->market_productType->getAll(); //first test product /** @var Market_ProductModel $product */ $product = Market_ProductModel::populateModel(['typeId' => $productTypes[0]->id, 'enabled' => 1, 'authorId' => \Craft\craft()->userSession->id, 'availableOn' => new DateTime(), 'expiresOn' => NULL, 'promotable' => 1, 'taxCategoryId' => \Craft\craft()->market_taxCategory->getDefaultId()]); $product->getContent()->title = 'Nice Shirt'; \Craft\craft()->market_product->save($product); //implicit variant /** @var Market_VariantModel $implicitVariant */ $implicitVariant = Market_VariantModel::populateModel(['productId' => $product->id, 'isImplicit' => 1, 'sku' => 'ABC', 'price' => 10, 'unlimitedStock' => 1]); \Craft\craft()->market_variant->save($implicitVariant); //another test product /** @var Market_ProductModel $product */ $product = Market_ProductModel::populateModel(['typeId' => $productTypes[0]->id, 'enabled' => 1, 'authorId' => \Craft\craft()->userSession->id, 'availableOn' => new DateTime(), 'expiresOn' => NULL, 'promotable' => 1, 'taxCategoryId' => \Craft\craft()->market_taxCategory->getDefaultId()]); $product->getContent()->title = 'Really Nice Shirt'; \Craft\craft()->market_product->save($product); //implicit variant $implicitVariant = Market_VariantModel::populateModel(['productId' => $product->id, 'isImplicit' => 1, 'sku' => 'CBA', 'price' => 20, 'unlimitedStock' => 1]); \Craft\craft()->market_variant->save($implicitVariant); }