public function index()
 {
     $clientData = App::getModel('client')->getClient();
     $this->registry->xajax->registerFunction(array('addProductToCart', App::getModel('cart/cart'), 'addAJAXProductToCart'));
     $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) {
             $Data[implode(',', array_keys($data['variant']))] = array('setid' => $group, 'stock' => $data['stock'], 'sellprice' => $this->registry->core->processPrice($data['sellprice']), 'sellpricenetto' => $this->registry->core->processPrice($data['sellpricenetto']));
         }
         $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);
         $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);
             }
         }
         $this->registry->template->assign('range', $range);
         $this->registry->template->assign('files', $files);
         $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('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'));
 }
Exemple #2
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'));
 }
Exemple #3
0
    protected function updateLayoutBoxContentTypeSpecificValues($idLayoutBox, $submittedData)
    {
        $this->deleteLayoutBoxContentTypeSpecificValues($idLayoutBox);
        $variables = array();
        switch ($submittedData['box']['box_content']) {
            case 'TextBox':
                $content = array();
                foreach ($submittedData['ct_TextBox']['textbox_content_translation'] as $languageid => $value) {
                    $content[$languageid] = $value['textbox_content'];
                }
                $variables['content'] = $content;
                break;
            case 'GraphicsBox':
                $variables['image'] = 'design/_images_frontend/upload/' . $submittedData['ct_GraphicsBox']['image']['file'];
                $size = getimagesize(ROOTPATH . $variables['image']);
                $variables['height'] = $size[1] - 10;
                $variables['align'] = $submittedData['ct_GraphicsBox']['align'];
                $variables['url'] = $submittedData['ct_GraphicsBox']['url'];
                break;
            case 'ProductDescriptionBox':
                $variables['tabbed'] = isset($submittedData['ct_ProductDescriptionBox']['tabbed']) && $submittedData['ct_ProductDescriptionBox']['tabbed'] ? '1' : '0';
                break;
            case 'ProductsInCategoryBox':
                $variables['productsCount'] = $submittedData['ct_ProductsInCategoryBox']['productsCount'];
                $variables['view'] = $submittedData['ct_ProductsInCategoryBox']['view'];
                // $variables['orderBy'] =
                // $submittedData['ct_ProductsInCategoryBox']['orderBy'];
                // $variables['orderDir'] =
                // $submittedData['ct_ProductsInCategoryBox']['orderDir'];
                $variables['pagination'] = isset($submittedData['ct_ProductsInCategoryBox']['pagination']) && $submittedData['ct_ProductsInCategoryBox']['pagination'] ? '1' : '0';
                break;
            case 'ProductSearchListBox':
                $variables['productsCount'] = $submittedData['ct_ProductSearchListBox']['productsCount'];
                $variables['view'] = $submittedData['ct_ProductSearchListBox']['view'];
                $variables['orderBy'] = $submittedData['ct_ProductSearchListBox']['orderBy'];
                $variables['orderDir'] = $submittedData['ct_ProductSearchListBox']['orderDir'];
                $variables['pagination'] = isset($submittedData['ct_ProductSearchListBox']['pagination']) && $submittedData['ct_ProductSearchListBox']['pagination'] ? '1' : '0';
                break;
            case 'ProductPromotionsBox':
                $variables['productsCount'] = $submittedData['ct_ProductPromotionsBox']['productsCount'];
                $variables['view'] = $submittedData['ct_ProductPromotionsBox']['view'];
                $variables['orderBy'] = $submittedData['ct_ProductPromotionsBox']['ct_ProductPromotionsBox_orderBy'];
                $variables['orderDir'] = $submittedData['ct_ProductPromotionsBox']['ct_ProductPromotionsBox_orderDir'];
                $variables['pagination'] = isset($submittedData['ct_ProductPromotionsBox']['pagination']) && $submittedData['ct_ProductPromotionsBox']['pagination'] ? '1' : '0';
                break;
            case 'ProductNewsBox':
                $variables['productsCount'] = $submittedData['ct_ProductNewsBox']['productsCount'];
                $variables['view'] = $submittedData['ct_ProductNewsBox']['view'];
                $variables['orderBy'] = $submittedData['ct_ProductNewsBox']['ct_ProductNewsBox_orderBy'];
                $variables['orderDir'] = $submittedData['ct_ProductNewsBox']['ct_ProductNewsBox_orderDir'];
                $variables['pagination'] = isset($submittedData['ct_ProductNewsBox']['pagination']) && $submittedData['ct_ProductNewsBox']['pagination'] ? '1' : '0';
                break;
            case 'ProductsCrossSellBox':
                $variables['productsCount'] = $submittedData['ct_ProductsCrossSellBox']['productsCount'];
                $variables['view'] = $submittedData['ct_ProductsCrossSellBox']['view'];
                $variables['orderBy'] = $submittedData['ct_ProductsCrossSellBox']['ct_ProductsCrossSellBox_orderBy'];
                $variables['orderDir'] = $submittedData['ct_ProductsCrossSellBox']['ct_ProductsCrossSellBox_orderDir'];
                break;
            case 'ProductsSimilarBox':
                $variables['productsCount'] = $submittedData['ct_ProductsSimilarBox']['productsCount'];
                $variables['view'] = $submittedData['ct_ProductsSimilarBox']['view'];
                $variables['orderBy'] = $submittedData['ct_ProductsSimilarBox']['ct_ProductsSimilarBox_orderBy'];
                $variables['orderDir'] = $submittedData['ct_ProductsSimilarBox']['ct_ProductsSimilarBox_orderDir'];
                break;
            case 'ProductsUpSellBox':
                $variables['productsCount'] = $submittedData['ct_ProductsUpSellBox']['productsCount'];
                $variables['view'] = $submittedData['ct_ProductsUpSellBox']['view'];
                $variables['orderBy'] = $submittedData['ct_ProductsUpSellBox']['ct_ProductsUpSellBox_orderBy'];
                $variables['orderDir'] = $submittedData['ct_ProductsUpSellBox']['ct_ProductsUpSellBox_orderDir'];
                break;
            case 'CategoriesBox':
                App::getModel('category')->flushCache();
                $variables['showcount'] = isset($submittedData['ct_CategoriesBox']['showcount']) && $submittedData['ct_CategoriesBox']['showcount'] ? '1' : '0';
                $variables['hideempty'] = isset($submittedData['ct_CategoriesBox']['hideempty']) && $submittedData['ct_CategoriesBox']['hideempty'] ? '1' : '0';
                $variables['showall'] = isset($submittedData['ct_CategoriesBox']['showall']) ? $submittedData['ct_CategoriesBox']['showall'] : 1;
                $variables['categoryIds'] = isset($submittedData['ct_CategoriesBox']['categoryIds']) && is_array($submittedData['ct_CategoriesBox']['categoryIds']) && count($submittedData['ct_CategoriesBox']['categoryIds']) > 0 ? implode(',', $submittedData['ct_CategoriesBox']['categoryIds']) : '';
                break;
            case 'MainCategoriesBox':
                $variables['showall'] = isset($submittedData['ct_MainCategoriesBox']['showall']) ? $submittedData['ct_MainCategoriesBox']['showall'] : 1;
                $variables['categoryIds'] = isset($submittedData['ct_MainCategoriesBox']['categoryIds']) && is_array($submittedData['ct_MainCategoriesBox']['categoryIds']) && count($submittedData['ct_MainCategoriesBox']['categoryIds']) > 0 ? implode(',', $submittedData['ct_MainCategoriesBox']['categoryIds']) : '';
                break;
            case 'ShowcaseBox':
                $variables['productsCount'] = $submittedData['ct_ShowcaseBox']['productsCount'];
                $variables['orderBy'] = $submittedData['ct_ShowcaseBox']['ct_ShowcaseBox_orderBy'];
                $variables['orderDir'] = $submittedData['ct_ShowcaseBox']['ct_ShowcaseBox_orderDir'];
                $variables['statusId'] = $submittedData['ct_ShowcaseBox']['statusId'];
                break;
            case 'ProductBestsellersBox':
                $variables['productsCount'] = $submittedData['ct_ProductBestsellersBox']['productsCount'];
                $variables['minProductsCount'] = $submittedData['ct_ProductBestsellersBox']['minProductsCount'];
                $variables['view'] = $submittedData['ct_ProductBestsellersBox']['view'];
                $variables['orderBy'] = $submittedData['ct_ProductBestsellersBox']['ct_ProductBestsellersBox_orderBy'];
                $variables['orderDir'] = $submittedData['ct_ProductBestsellersBox']['ct_ProductBestsellersBox_orderDir'];
                break;
            case 'CustomProductListBox':
                $variables['productsCount'] = $submittedData['ct_CustomProductListBox']['productsCount'];
                $variables['view'] = $submittedData['ct_CustomProductListBox']['view'];
                $variables['orderBy'] = $submittedData['ct_CustomProductListBox']['ct_CustomProductListBox_orderBy'];
                $variables['orderDir'] = $submittedData['ct_CustomProductListBox']['ct_CustomProductListBox_orderDir'];
                $variables['products'] = isset($submittedData['ct_CustomProductListBox']['custom_products']) ? implode(',', $submittedData['ct_CustomProductListBox']['custom_products']) : '';
                break;
            case 'SitemapBox':
                $variables['categoryTreeLevels'] = $submittedData['ct_SitemapBox']['categoryTreeLevels'];
                break;
            case 'SlideShowBox':
                for ($i = 1; $i <= 10; $i++) {
                    if ($submittedData['ct_SlideShowBox']['image' . $i]['file'] != '') {
                        $variables['image' . $i] = 'design/_images_frontend/upload/' . $submittedData['ct_SlideShowBox']['image' . $i]['file'];
                        $size = getimagesize(ROOTPATH . $variables['image' . $i]);
                        $variables['height' . $i] = $size[1];
                        $variables['url' . $i] = $submittedData['ct_SlideShowBox']['url' . $i];
                        $variables['caption' . $i] = $submittedData['ct_SlideShowBox']['caption' . $i];
                    }
                }
                break;
            case 'ProducerBox':
                $variables['view'] = $submittedData['ct_ProducerBox']['view'];
                $variables['producers'] = isset($submittedData['ct_ProducerBox']['producers']) ? implode(',', $submittedData['ct_ProducerBox']['producers']) : '';
                break;
            case 'ProducerListBox':
                $variables['productsCount'] = $submittedData['ct_ProducerListBox']['productsCount'];
                $variables['view'] = $submittedData['ct_ProducerListBox']['view'];
                $variables['pagination'] = isset($submittedData['ct_ProducerListBox']['pagination']) && $submittedData['ct_ProducerListBox']['pagination'] ? '1' : '0';
                break;
        }
        $eventData = Event::filter($this, 'admin.layoutbox.updateLayoutBoxContentTypeSpecificValues', array('variables' => $variables, 'submittedData' => $submittedData));
        foreach ($eventData as $Data) {
            $variables = \Gekosale\Arr::merge($variables, $Data);
        }
        foreach ($variables as $variable => $value) {
            if (is_array($value)) {
                foreach ($value as $languageid => $translatedValue) {
                    $sql = '
							INSERT
							INTO
								layoutboxcontentspecificvalue (
									layoutboxid,
									variable,
									value,
									languageid
								)
							VALUES (
								:id,
								:variable,
								:value,
								:languageid
							)
						';
                    $stmt = Db::getInstance()->prepare($sql);
                    $stmt->bindValue('id', $idLayoutBox);
                    $stmt->bindValue('variable', $variable);
                    $stmt->bindValue('value', $translatedValue);
                    $stmt->bindValue('languageid', $languageid);
                    $stmt->execute();
                }
            } else {
                $sql = '
						INSERT
						INTO
							layoutboxcontentspecificvalue (
								layoutboxid,
								variable,
								value
							)
						VALUES (
							:id,
							:variable,
							:value
						)
					';
                $stmt = Db::getInstance()->prepare($sql);
                $stmt->bindValue('id', $idLayoutBox);
                $stmt->bindValue('variable', $variable);
                $stmt->bindValue('value', $value);
                $stmt->execute();
            }
        }
    }