protected function displayEdit() { $item = $this->getItem(); if (empty($item) || $item->product_type != 'giftcards') { \Dsc\System::addMessage('Item is not a giftcard', 'error'); $this->app->reroute('/admin/shop/giftcards'); } $f3 = \Base::instance(); $flash = \Dsc\Flash::instance(); $variants = array(); if ($flashed_variants = $flash->old('variants')) { foreach ($flashed_variants as $variant) { $key = implode("-", (array) $variant['attributes']); if (empty($key)) { $key = $variant['id']; } $variants[$key] = $variant; } } $old = array_merge($flash->get('old'), array('variants' => $variants)); $flash->store($old); $model = new \Shop\Models\Categories(); $categories = $model->getList(); \Base::instance()->set('categories', $categories); \Base::instance()->set('selected', 'null'); $all_tags = $this->getModel()->getTags(); \Base::instance()->set('all_tags', $all_tags); $this->app->set('meta.title', 'Edit Gift Card | Shop'); $view = \Dsc\System::instance()->get('theme'); $view->event = $view->trigger('onDisplayShopProductsEdit', array('item' => $this->getItem(), 'tabs' => array(), 'content' => array())); echo $view->render('Shop\\Admin\\Views::giftcards/edit.php'); }
protected function displayCreate() { $model = new \Shop\Models\Categories(); $categories = $model->getList(); $this->app->set('categories', $categories); $this->app->set('selected', 'null'); $item = $this->getItem(); $selected = array(); $flash = \Dsc\Flash::instance(); $use_flash = \Dsc\System::instance()->getUserState('use_flash.' . $this->create_item_route); if (!$use_flash) { // this is a brand-new create, so store the prefab data $flash->store($item->cast()); } $input = $flash->old('category_ids'); if (!empty($input)) { foreach ($input as $id) { $id = $this->inputfilter->clean($id, 'alnum'); $selected[] = array('id' => $id); } } $flash->store($flash->get('old') + array('categories' => $selected)); $all_tags = $this->getModel()->getTags(); $this->app->set('all_tags', $all_tags); $this->app->set('meta.title', 'Create Product | Shop'); $view = \Dsc\System::instance()->get('theme'); $view->event = $view->trigger('onDisplayShopProductsEdit', array('item' => $item, 'tabs' => array(), 'content' => array())); switch ($item->product_type) { case "giftcard": case "giftcards": echo $view->render('Shop\\Admin\\Views::giftcards/create.php'); break; default: echo $view->render('Shop\\Admin\\Views::products/create.php'); break; } }
protected function displayEdit() { $item = $this->getItem(); $flash = \Dsc\Flash::instance(); $variants = array(); if ($flashed_variants = $flash->old('variants')) { foreach ($flashed_variants as $variant) { $key = implode("-", (array) $variant['attributes']); if (empty($key)) { $key = $variant['id']; } $variants[$key] = $variant; } } $old = array_merge($flash->get('old'), array('variants' => $variants)); $flash->store($old); $model = new \Shop\Models\Categories(); $categories = $model->getList(); $this->app->set('categories', $categories); $this->app->set('selected', 'null'); $all_tags = $this->getModel()->getTags(); $this->app->set('all_tags', $all_tags); $this->app->set('meta.title', 'Edit Product | Shop'); $this->app->set('allow_preview', $this->canPreview(true)); $view = \Dsc\System::instance()->get('theme'); $view->event = $view->trigger('onDisplayShopProductsEdit', array('item' => $item, 'tabs' => array(), 'content' => array())); switch ($item->product_type) { case "giftcard": case "giftcards": echo $view->render('Shop\\Admin\\Views::giftcards/edit.php'); break; default: echo $view->render('Shop\\Admin\\Views::products/edit.php'); break; } }