Пример #1
0
 /**
  * Index page
  * 
  * @access  public
  * @param   $slug
  */
 public function action_index($slug = false, $my_products = null)
 {
     $category_parents = false;
     if ($my_products == 1) {
         Model_Product::$filter_by_pricing_group = 'assigned';
     } else {
         Model_Product::$filter_by_pricing_group = 'not_assigned';
     }
     if ($product = Model_Product::get_by_slug($slug)) {
         // Find main category
         if (!empty($product->categories)) {
             $parents = array();
             if ($category_parents_id = Model_Category::find_parents(key($product->categories), $parents, true)) {
                 $category_parents = Model_Category::find(array('where' => array(array('id', 'in', $category_parents_id))));
             }
         }
         \Theme::instance()->set_partial('content', $this->view_dir . 'product')->set('product', $product, false)->set('category_parents', $category_parents, false)->set('product_data', $product->data, false);
     } else {
         throw new \HttpNotFoundException();
     }
 }
Пример #2
0
 /**
  * Index page
  * 
  * @access  public
  * @param   $slug
  */
 public function action_index($slug = false, $my_products = null)
 {
     $category_parents = false;
     if ($my_products == 1) {
         Model_Product::$filter_by_pricing_group = 'assigned';
     } else {
         Model_Product::$filter_by_pricing_group = 'not_assigned';
     }
     if ($product = Model_Product::get_by_slug($slug)) {
         // Find main category
         if (!empty($product->categories)) {
             $parents = array();
             if ($category_parents_id = Model_Category::find_parents(key($product->categories), $parents, true)) {
                 $category_parents = Model_Category::find(array('where' => array(array('id', 'in', $category_parents_id))));
             }
         }
         $stock_options = \Config::load('stock-option.db');
         if ($product->attributes[0]->stock_quantity > 0 || $stock_options['manage_stock'] && $product->attributes[0]->stock_quantity < 1 && $stock_options['hide_out_of_stock'] == 0) {
             \Theme::instance()->set_partial('content', $this->view_dir . 'product')->set('product', $product, false)->set('category_parents', $category_parents, false)->set('product_data', $product->data, false)->set('allow_buy_out_of_stock', $stock_options['allow_buy_out_of_stock']);
         } else {
             \Messages::error('Item is not available.');
             \Response::redirect('page/products');
         }
         \View::set_global('title', $product->seo->meta_title ?: $product->title);
         \View::set_global('meta_description', $product->seo->meta_description ?: '');
         \View::set_global('meta_keywords', $product->seo->meta_keywords ?: '');
         $robots = array('meta_robots_index' => $product->seo->meta_robots_index == 1 ? 'index' : 'noindex', 'meta_robots_follow' => $product->seo->meta_robots_follow == 1 ? 'follow' : 'nofollow');
         \View::set_global('robots', $robots);
         \View::set_global('canonical', $product->seo->canonical_links);
         \View::set_global('h1_tag', $product->seo->h1_tag);
         if ($product->seo->redirect_301) {
             \Response::redirect($product->seo->redirect_301);
         }
     } else {
         throw new \HttpNotFoundException();
     }
 }