/** * * */ protected function createProducts() { $this->alterationMessage("================================================ CREATING PRODUCTS ================================================", "show"); $productsCompleted = array(); foreach ($this->csv as $row) { if (!isset($productsCompleted[$row["ProductTitle"]])) { $filterArray = array("Title" => $row["ProductTitle"], "InternalItemID" => $row["ProductInternalItemID"]); $product = ProductPage::get()->filterAny($filterArray)->first(); if ($product && $product->ParentID) { $this->defaultProductParentID = $product->ParentID; } elseif (!$this->defaultProductParentID) { $this->defaultProductParentID = ProductGroup::get()->first()->ID; } if (!$product) { $product = ProductPage::create($filterArray); $product->MenuTitle = $row["ProductTitle"]; $this->alterationMessage("Creating Product: " . $row["ProductTitle"], "created"); } else { $this->alterationMessage("Product: " . $row["ProductTitle"] . " already exists"); } if (!$product->ParentID) { $product->ParentID = $this->defaultProductParentID; } $product->Title = $row["ProductTitle"]; $product->InternalItemID = $row["ProductInternalItemID"]; if ($this->forreal) { $this->addMoreProduct($product, $row); $product->write("Stage"); if ($product->IsPublished()) { $product->Publish('Stage', 'Live'); } } $productsCompleted[$row["ProductTitle"]] = $product->ID; $this->data[$product->ID] = array("Product" => $product, "VariationRows" => array()); } } $this->alterationMessage("================================================", "show"); }