function action_create() { PermissionHelper::Verification('Editor'); $c = $_POST['c']; if (!is_null($c)) { $model = ProductHelper::PopulateProductCreateViewModel(CatalogueService::GetByName($c)); $this->view->generate('/Product/create_view.php', 'template_view.php', $model); } else { header("Location: /Product/SelectCatalog"); } }
function action_new() { PermissionHelper::Verification('Editor'); $name = $_POST['inputName']; $sectionName = $_POST['inputSection']; $attribute = $_POST['attributes']; $catalogue = new Catalogue(); $catalogue->name = $name; $catalogue->section_id = SectionService::GetByName($sectionName)->section_id; CatalogueService::Create($catalogue); $catalogue = CatalogueService::GetByName($name); for ($i = 0; $i < count($attribute); $i++) { $value = new CatalogueAttribute(); $value->catalogue_id = $catalogue->catalogue_id; $value->attribute_id = AttributeService::GetByName(trim($attribute[$i]))->attribute_id; CatalogueAttributeService::Create($value); } header("Location: /Catalog/Item"); }
public static function GetByCatalogue($catalogueName) { return Product::find('all', array('catalogue_id' => CatalogueService::GetByName($catalogueName)->catalogue_id)); }