/**
  * Display product
  * @param string $url product url
  */
 public function actionView($seo_alias)
 {
     $this->_loadModel($seo_alias);
     $this->registerSessionViews($this->model->id);
     Yii::app()->clientScript->registerScriptFile($this->module->assetsUrl . '/product.view.js', CClientScript::POS_END);
     Yii::app()->clientScript->registerScriptFile($this->module->assetsUrl . '/product.view.configurations.js', CClientScript::POS_END);
     if ($this->model->mainCategory) {
         $ancestors = $this->model->mainCategory->excludeRoot()->ancestors()->findAll();
         // $this->breadcrumbs = array(Yii::t('ShopModule.default', 'BC_SHOP') => '/shop');
         foreach ($ancestors as $c) {
             $this->breadcrumbs[$c->name] = $c->getViewUrl();
         }
         //
         // Do not add root category to breadcrumbs
         if ($this->model->mainCategory->id != 1) {
             //$bc[$this->model->mainCategory->name]=$this->model->mainCategory->getViewUrl();
             $this->breadcrumbs[$this->model->mainCategory->name] = $this->model->mainCategory->getViewUrl();
         }
         $this->breadcrumbs[] = $this->model->name;
     }
     $this->pageKeywords = $this->model->keywords();
     $this->pageDescription = $this->model->description();
     $this->pageTitle = $this->model->title();
     $this->render('view', array('model' => $this->model));
 }
Beispiel #2
0
/**
* @desc Elimina de la base de datos la información del trabajo
**/
function shop_delete_products()
{
    global $xoopsSecurity, $xoopsModule;
    $ids = rmc_server_var($_POST, 'ids', 0);
    $page = rmc_server_var($_POST, 'page', 1);
    $bname = rmc_server_var($_POST, 'bname', '');
    $ruta = "page={$page}&bname={$bname}";
    //Verificamos que nos hayan proporcionado un trabajo para eliminar
    if (!is_array($ids)) {
        redirectMsg('products.php?' . $ruta, __('You must select one product at least!', 'shop'), 1);
        die;
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('products.php?' . $ruta, __('Session token expired!', 'shop'), 1);
        die;
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si el trabajo es válido
        if ($k <= 0) {
            $errors .= sprintf(__('Product ID "%s" is not valid!', 'shop'), $k);
            continue;
        }
        //Verificamos si el trabajo existe
        $product = new ShopProduct($k);
        if ($product->isNew()) {
            $errors .= sprintf(__('Product with ID "%s" does not exists!', 'shop'), $k);
            continue;
        }
        if (!$product->delete()) {
            $errors .= sprintf(__('Product "%s" could not be deleted!', 'shop'), $product->title());
        }
    }
    if ($errors != '') {
        redirectMsg('products.php?' . $ruta, __('Errors ocurred while trying to delete products', 'shop') . '<br />' . $errors, 1);
        die;
    } else {
        redirectMsg('products.php?' . $ruta, __('Prodducts deleted successfully!', 'shop'), 0);
        die;
    }
}