Example #1
0
 public function index()
 {
     $clientData = App::getModel('client')->getClient();
     $this->registry->xajax->registerFunction(array('addOpinion', $this->productModel, 'addAJAXOpinionAboutProduct'));
     //$this->registry->xajax->registerFunction(array(
     //'addProductRangeOpinion',
     //$this->productModel,
     //'addAJAXProductRangeOpinion'
     //));
     if (isset($this->_boxAttributes['tabbed'])) {
         $tabbed = $this->_boxAttributes['tabbed'];
     } else {
         $tabbed = 1;
     }
     if (isset($this->product['idproduct'])) {
         $range = $this->productModel->getRangeType((int) $this->productid);
         $this->productModel->getPhotos($this->product);
         $this->productModel->getOtherPhotos($this->product);
         $selectAttributes = $this->productModel->getProductAttributeGroups($this->product);
         foreach ($selectAttributes as $key => $val) {
             natsort($val['attributes']);
             $selectAttributes[$key]['attributes'] = $val['attributes'];
         }
         $attset = $this->productModel->getProductVariant($this->product);
         $Data = array();
         foreach ($attset as $group => $data) {
             $keys = array_keys($data['variant']);
             natsort($keys);
             $Data[implode(',', $keys)] = array('setid' => $group, 'stock' => $data['stock'], 'sellprice' => $this->registry->core->processPrice($data['sellprice']), 'sellpricenetto' => $this->registry->core->processPrice($data['sellpricenetto']), 'sellpriceold' => $this->registry->core->processPrice($data['attributepricegrossbeforepromotion']), 'sellpricenettoold' => $this->registry->core->processPrice($data['attributepricenettobeforepromotion']), 'availablity' => $data['availablity'], 'photos' => $data['photos']);
         }
         $productreview = App::getModel('productreview')->getProductReviews((int) $this->productid);
         $delivery = App::getModel('delivery')->getDispatchmethodPriceForProduct($this->product['price'], $this->product['weight']);
         $deliverymin = PHP_INT_MAX;
         foreach ($delivery as $i) {
             $deliverymin = min($deliverymin, $i['dispatchmethodcost']);
         }
         $files = App::getModel('product')->getFilesByProductId((int) $this->productid);
         $warranty = App::getModel('product')->getWarrantyByProductId((int) $this->productid);
         $tabs = $this->registry->template->assign('tabbed', $tabbed);
         $eventData = Event::filter($this, 'frontend.productbox.assign', array(), NULL);
         foreach ($eventData as $Data) {
             foreach ($Data as $tab => $values) {
                 $this->registry->template->assign($tab, $values);
             }
         }
         $opinion = Session::getVolatileOpinionAdded();
         if ($opinion[0] == 1) {
             $this->registry->template->assign('opinionadded', _('TXT_CLIENT_OPINION_ADDED'));
         } elseif ($opinion[0] == 2) {
             $this->registry->template->assign('opinionadded', _('TXT_GUEST_OPINION_ADDED'));
         }
         if ($this->product['enable'] == 0 && (int) Session::getActiveUserid() > 0) {
             $this->registry->template->assign('draft', _('TXT_PRODUCT_DRAFT'));
         }
         $this->registry->template->assign('range', $range);
         $this->registry->template->assign('files', $files);
         $this->registry->template->assign('warranty', $warranty);
         $this->registry->template->assign('variants', json_encode($Data));
         $this->registry->template->assign('product', $this->product);
         $this->registry->template->assign('attributes', $selectAttributes);
         $this->registry->template->assign('attset', $attset);
         $this->registry->template->assign('humanProductReviewCount', App::getModel('productreview')->getHumanOpinionsCount(count($productreview)));
         $this->registry->template->assign('productreview', $productreview);
         $this->registry->template->assign('delivery', $delivery);
         $this->registry->template->assign('deliverymin', $deliverymin);
         $this->productModel->updateViewedCount((int) $this->productid);
     } else {
         App::redirectSeo(App::getURLAdress());
     }
     return $this->registry->template->fetch($this->loadTemplate('index.tpl'));
 }