Пример #1
0
 public function init()
 {
     // Get product details from business tier
     $this->mProduct = Catalog::GetProductDetails($this->_mProductId);
     if (isset($_SESSION['link_to_continue_shopping'])) {
         $continue_shopping = Link::QueryStringToArray($_SESSION['link_to_continue_shopping']);
         $page = 1;
         if (isset($continue_shopping['Page'])) {
             $page = (int) $continue_shopping['Page'];
         }
         if (isset($continue_shopping['CategoryId'])) {
             $this->mLinkToContinueShopping = Link::ToCategory((int) $continue_shopping['DepartmentId'], (int) $continue_shopping['CategoryId'], $page);
         } elseif (isset($continue_shopping['DepartmentId'])) {
             $this->mLinkToContinueShopping = Link::ToDepartment((int) $continue_shopping['DepartmentId'], $page);
         } elseif (isset($continue_shopping['SearchResults'])) {
             $this->mLinkToContinueShopping = Link::ToSearchResults(trim(str_replace('-', ' ', $continue_shopping['SearchString'])), $continue_shopping['AllWords'], $page);
         } else {
             $this->mLinkToContinueShopping = Link::ToIndex($page);
         }
     }
     if ($this->mProduct['image']) {
         $this->mProduct['image'] = Link::Build('images/product_images/' . $this->mProduct['image']);
     }
     if ($this->mProduct['image_2']) {
         $this->mProduct['image_2'] = Link::Build('images/product_images/' . $this->mProduct['image_2']);
     }
     $this->mProduct['attributes'] = Catalog::GetProductAttributes($this->mProduct['product_id']);
     $this->mLocations = Catalog::GetProductLocations($this->_mProductId);
     // Create the Add to Cart link
     $this->mProduct['link_to_add_product'] = Link::ToCart(ADD_PRODUCT, $this->_mProductId);
     // Build links for product departments and categories pages
     for ($i = 0; $i < count($this->mLocations); $i++) {
         $this->mLocations[$i]['link_to_department'] = Link::ToDepartment($this->mLocations[$i]['department_id']);
         $this->mLocations[$i]['link_to_category'] = Link::ToCategory($this->mLocations[$i]['department_id'], $this->mLocations[$i]['category_id']);
     }
     // Подготавливаем кнопу редактирования
     $this->mEditActionTarget = Link::Build(str_replace(VIRTUAL_LOCATION, '', getenv('REQUEST_URI')));
     if (isset($_SESSION['admin_logged']) && $_SESSION['admin_logged'] == TRUE && isset($_POST['submit_edit'])) {
         $product_locations = $this->mLocations;
         if (count($product_locations) > 0) {
             $department_id = $product_locations[0]['department_id'];
             $category_id = $product_locations[0]['category_id'];
             header('Location: ' . htmlspecialchars_decode(Link::ToProductAdmin($department_id, $category_id, $this->_mProductId)));
         }
     }
 }
Пример #2
0
 public function init()
 {
     // Get product details from business tier
     $this->mProduct = Catalog::GetProductDetails($this->_mProductId);
     // Session Handle
     if (isset($_SESSION['link_to_continue_shopping'])) {
         $continue_shopping = Link::QueryStringToArray($_SESSION['link_to_continue_shopping']);
         $page = 1;
         // Cache the current query string. Then after choose the product, we will get back this page.
         if (isset($continue_shopping['Page'])) {
             $page = (int) $continue_shopping['Page'];
         }
         if (isset($continue_shopping['CategoryId'])) {
             $this->mLinkToContinueShopping = Link::ToCategory((int) $continue_shopping['DepartmentId'], (int) $continue_shopping['CategoryId'], $page);
         } elseif (isset($continue_shopping['DepartmentId'])) {
             $this->mLinkToContinueShopping = Link::ToDepartment((int) $continue_shopping['DepartmentId'], $page);
         } else {
             $this->mLinkToContinueShopping = Link::ToIndex($page);
         }
     }
     // Product detail
     if ($this->mProduct['image']) {
         $this->mProduct['image'] = Link::Build('images/product_images/' . $this->mProduct['image']);
     }
     if ($this->mProduct['image_2']) {
         $this->mProduct['image_2'] = Link::Build('images/product_images/' . $this->mProduct['image_2']);
     }
     $this->mProduct['attributes'] = Catalog::GetProductAttributes($this->mProduct['product_id']);
     // Similar products in catalog
     $this->mLocations = Catalog::GetProductLocations($this->_mProductId);
     // Build links for product departments and categories pages
     for ($i = 0; $i < count($this->mLocations); $i++) {
         $this->mLocations[$i]['link_to_department'] = Link::ToDepartment($this->mLocations[$i]['department_id']);
         $this->mLocations[$i]['link_to_category'] = Link::ToCategory($this->mLocations[$i]['department_id'], $this->mLocations[$i]['category_id']);
     }
 }