$alias_url = $category->val('alias_url'); unset($category->data['alias_url']); $category->save(); $alias = new Alias($db, $category->ival('category_alias_id')); // save alias if new or changed if ($alias->val('alias_url') != $alias_url || !$alias->is_loaded) { $alias->data['alias_path'] = $category->getAliasPath(); if (isset($alias_url) && strlen(trim($alias_url)) > 0) { $alias->setUrl($alias_url); } else { $alias->setUrl($category->getAliasUrl()); } $alias->save(); } // update category alias if changed if ($alias->ival('alias_id') != $category->ival('category_alias_id')) { $category->data['category_alias_id'] = $alias->ival('alias_id'); $category->save(); } $category->alias = $alias; } elseif (isset($path[2]) && $path[2] == 'edit') { $category = new Category($db, $path[3]); $category->alias = new Alias($db, $category->val('category_alias_id')); $page_title = t('Editing Category'); } elseif (isset($path[2]) && $path[2] == 'delete') { $category = new Category($db); $category->deleteById($path[3]); redirect('/admin/categories'); } else { $category = new Category($db); $page_title = t('New Category');
$zCategory = $category; } } if (isset($zCategory)) { $zProduct->data['product_category_id'] = $zCategory->ival('category_id'); $zProduct->data['product_name'] = $product_name; $zProduct->data['product_price'] = $product_price; $zProduct->data['product_stock'] = $product_stock; $zProduct->save(); // update alias $a = new Alias($db, $zProduct->val('product_alias_id')); if (!$a->is_loaded) { $a->setUrl($zProduct->getAliasUrl()); $a->data['alias_path'] = $zProduct->getAliasPath(); $a->save(); $zProduct->data['product_alias_id'] = $a->ival('alias_id'); $zProduct->save(); } } else { echo sprintf('Cannot find category with ABX id %s for product "%s"<br/>', $cat, $product_name); } } } // if $save_product if (isset($zVariant) && $zProduct->val('product_id') != null) { $zVariant->data['product_variant_ext_id'] = $prod_id; $zVariant->data['product_variant_name'] = $variant_name; $zVariant->data['product_variant_product_id'] = $zProduct->ival('product_id'); $zVariant->data['product_variant_price'] = $product_price; $zVariant->data['product_variant_stock'] = $product_stock; try {