/** * Edit a SKU * * @return void */ public function editTask($row = null) { Request::setVar('hidemainmenu', 1); $obj = new Archive(); if (is_object($row)) { $id = $row->getId(); // If this is a new SKU, set product ID if (!$id) { $pId = Request::getVar('pId'); $row->setProductId($pId); } $this->view->row = $row; $this->view->task = 'edit'; } else { // Incoming $id = Request::getVar('id', array(0)); if (is_array($id) && !empty($id)) { $id = $id[0]; } // Get correct SKU instance $pId = Request::getVar('pId'); if ($id) { $row = Sku::getInstance($id); } elseif ($pId) { // create new SKU $row = Sku::newInstance($pId); } else { throw new \Exception('SKU was not found'); } $this->view->row = $row; } // Get product's info $pId = $row->getProductId(); $warehouse = new Warehouse(); $pInfo = $warehouse->getProductInfo($pId, true); $this->view->pInfo = $pInfo; //print_r($pInfo); die; // Get available product-defined option groups and options $this->view->allOptions = $obj->getProductOptions($pId); // Get current SKU options $this->view->options = $row->getOptions(); // Get number of downloads $downloaded = CartDownload::countSkuDownloads($id); $this->view->downloaded = $downloaded; // Set any errors foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Output the HTML $this->view->setLayout('edit')->display(); }