예제 #1
0
 function _updateStatus($order_id, $order_status, $status_id, $notify, $comments, $include, $view_order)
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $client_id = JRequest::getInt('client_id', 0);
     JPluginHelper::importPlugin('jshoppingorder');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeChangeOrderStatusAdmin', array(&$order_id, &$order_status, &$status_id, &$notify, &$comments, &$include, &$view_order));
     $order = JTable::getInstance('order', 'jshop');
     $order->load($order_id);
     JSFactory::loadLanguageFile($order->getLang());
     $prev_order_status = $order->order_status;
     $order->order_status = $order_status;
     $order->order_m_date = getJsDate();
     $order->store();
     $vendorinfo = $order->getVendorInfo();
     if (in_array($order_status, $jshopConfig->payment_status_return_product_in_stock) && !in_array($prev_order_status, $jshopConfig->payment_status_return_product_in_stock)) {
         $order->changeProductQTYinStock("+");
     }
     if (in_array($prev_order_status, $jshopConfig->payment_status_return_product_in_stock) && !in_array($order_status, $jshopConfig->payment_status_return_product_in_stock)) {
         $order->changeProductQTYinStock("-");
     }
     $order_history = JTable::getInstance('orderHistory', 'jshop');
     $order_history->order_id = $order_id;
     $order_history->order_status_id = $order_status;
     $order_history->status_date_added = getJsDate();
     $order_history->customer_notify = $notify;
     $order_history->comments = $comments;
     $order_history->store();
     if ($jshopConfig->admin_show_vendors) {
         $listVendors = $order->getVendors();
     } else {
         $listVendors = array();
     }
     $vendors_send_message = $jshopConfig->vendor_order_message_type == 1 || $order->vendor_type == 1 && $jshopConfig->vendor_order_message_type == 2;
     $vendor_send_order = $jshopConfig->vendor_order_message_type == 2 && $order->vendor_type == 0 && $order->vendor_id;
     if ($jshopConfig->vendor_order_message_type == 3) {
         $vendor_send_order = 1;
     }
     $admin_send_order = 1;
     if ($jshopConfig->admin_not_send_email_order_vendor_order && $vendor_send_order && count($listVendors)) {
         $admin_send_order = 0;
     }
     $lang = JSFactory::getLang($order->getLang());
     $new_status = JTable::getInstance('orderStatus', 'jshop');
     $new_status->load($order_status);
     $comments = $include ? $comments : '';
     $name = $lang->get('name');
     $shop_item_id = getShopMainPageItemid();
     $juri = JURI::getInstance();
     $liveurlhost = $juri->toString(array("scheme", 'host', 'port'));
     $app = JApplication::getInstance('site');
     $router = $app->getRouter();
     $uri = $router->build('index.php?option=com_jshopping&controller=user&task=order&order_id=' . $order_id . "&Itemid=" . $shop_item_id);
     $url = $uri->toString();
     $order_details_url = $liveurlhost . str_replace('/administrator', '', $url);
     if ($order->user_id == -1) {
         $order_details_url = '';
     }
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     $view = $this->getView("orders", 'html');
     $view->setLayout("statusorder");
     $view->assign('order', $order);
     $view->assign('comment', $comments);
     $view->assign('order_status', $new_status->{$name});
     $view->assign('vendorinfo', $vendorinfo);
     $view->assign('order_detail', $order_details_url);
     $dispatcher->trigger('onBeforeCreateMailOrderStatusView', array(&$view));
     $message = $view->loadTemplate();
     //message client
     if ($notify) {
         $subject = sprintf(_JSHOP_ORDER_STATUS_CHANGE_SUBJECT, $order->order_number);
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->addRecipient($order->email);
         $mailer->setSubject($subject);
         $mailer->setBody($message);
         $mailer->isHTML(false);
         $send = $mailer->Send();
     }
     //message vendors
     if ($vendors_send_message || $vendor_send_order) {
         $subject = sprintf(_JSHOP_ORDER_STATUS_CHANGE_SUBJECT, $order->order_number);
         foreach ($listVendors as $k => $datavendor) {
             $mailer = JFactory::getMailer();
             $mailer->setSender(array($mailfrom, $fromname));
             $mailer->addRecipient($datavendor->email);
             $mailer->setSubject($subject);
             $mailer->setBody($message);
             $mailer->isHTML(false);
             $send = $mailer->Send();
         }
     }
     JSFactory::loadAdminLanguageFile();
     $dispatcher->trigger('onAfterChangeOrderStatusAdmin', array(&$order_id, &$order_status, &$status_id, &$notify, &$comments, &$include, &$view_order));
     if ($view_order) {
         $this->setRedirect("index.php?option=com_jshopping&controller=orders&task=show&order_id=" . $order_id, _JSHOP_ORDER_STATUS_CHANGED);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=orders&client_id=" . $client_id, _JSHOP_ORDER_STATUS_CHANGED);
     }
 }
예제 #2
0
function getFullUrlSefLink($link, $useDefaultItemId = 0, $redirect = 0, $ssl = null)
{
    $app = JFactory::getApplication();
    $liveurlhost = JURI::getInstance()->toString(array("scheme", 'host', 'port'));
    if ($app->isAdmin()) {
        $shop_item_id = getShopMainPageItemid();
        $app = JApplication::getInstance('site');
        $router = $app->getRouter();
        if (!preg_match('/Itemid=/', $link)) {
            if (!preg_match('/\\?/', $link)) {
                $sp = "?";
            } else {
                $sp = "&";
            }
            $link .= $sp . "Itemid=" . $shop_item_id;
        }
        $uri = $router->build($link);
        $url = $uri->toString();
        $fullurl = $liveurlhost . str_replace('/administrator', '', $url);
    } else {
        $fullurl = $liveurlhost . SEFLink($link, $useDefaultItemId, $redirect, $ssl);
    }
    return $fullurl;
}
예제 #3
0
function getDefaultItemid()
{
    return getShopMainPageItemid();
}
예제 #4
0
 function display($cachable = false, $urlparams = false)
 {
     $mainframe = JFactory::getApplication();
     $db = JFactory::getDBO();
     $ajax = JRequest::getInt('ajax');
     $jshopConfig = JSFactory::getConfig();
     $user = JFactory::getUser();
     JSFactory::loadJsFilesLightBox();
     $session = JFactory::getSession();
     $tmpl = JRequest::getVar("tmpl");
     if ($tmpl != "component") {
         $session->set("jshop_end_page_buy_product", $_SERVER['REQUEST_URI']);
     }
     $product_id = JRequest::getInt('product_id');
     $category_id = JRequest::getInt('category_id');
     $attr = JRequest::getVar("attr");
     $back_value = $session->get('product_back_value');
     if (!isset($back_value['pid'])) {
         $back_value = array('pid' => null, 'attr' => null, 'qty' => null);
     }
     if ($back_value['pid'] != $product_id) {
         $back_value = array('pid' => null, 'attr' => null, 'qty' => null);
     }
     if (!is_array($back_value['attr'])) {
         $back_value['attr'] = array();
     }
     if (count($back_value['attr']) == 0 && is_array($attr)) {
         $back_value['attr'] = $attr;
     }
     JPluginHelper::importPlugin('jshoppingproducts');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeLoadProduct', array(&$product_id, &$category_id, &$back_value));
     $dispatcher->trigger('onBeforeLoadProductList', array());
     $product = JTable::getInstance('product', 'jshop');
     $product->load($product_id);
     $listcategory = $product->getCategories(1);
     if (!getDisplayPriceForProduct($product->product_price)) {
         $jshopConfig->attr_display_addprice = 0;
     }
     $attributesDatas = $product->getAttributesDatas($back_value['attr']);
     $product->setAttributeActive($attributesDatas['attributeActive']);
     $attributeValues = $attributesDatas['attributeValues'];
     $attributes = $product->getBuildSelectAttributes($attributeValues, $attributesDatas['attributeSelected']);
     if (count($attributes)) {
         $_attributevalue = JTable::getInstance('AttributValue', 'jshop');
         $all_attr_values = $_attributevalue->getAllAttributeValues();
     } else {
         $all_attr_values = array();
     }
     $session->set('product_back_value', array());
     $product->getExtendsData();
     $category = JTable::getInstance('category', 'jshop');
     $category->load($category_id);
     $category->name = $category->getName();
     $dispatcher->trigger('onBeforeCheckProductPublish', array(&$product, &$category, &$category_id, &$listcategory));
     if ($category->category_publish == 0 || $product->product_publish == 0 || !in_array($product->access, $user->getAuthorisedViewLevels()) || !in_array($category_id, $listcategory)) {
         JError::raiseError(404, _JSHOP_PAGE_NOT_FOUND);
         return;
     }
     if (getShopMainPageItemid() == JRequest::getInt('Itemid')) {
         appendExtendPathway($category->getTreeChild(), 'product');
     }
     appendPathWay($product->name);
     if ($product->meta_title == "") {
         $product->meta_title = $product->name;
     }
     setMetaData($product->meta_title, $product->meta_keyword, $product->meta_description);
     $product->hit();
     $product->product_basic_price_unit_qty = 1;
     if ($jshopConfig->admin_show_product_basic_price) {
         $product->getBasicPriceInfo();
     } else {
         $product->product_basic_price_show = 0;
     }
     $view_name = "product";
     $view_config = array("template_path" => JPATH_COMPONENT . "/templates/" . $jshopConfig->template . "/" . $view_name);
     $view = $this->getView($view_name, getDocumentType(), '', $view_config);
     if ($product->product_template == "") {
         $product->product_template = "default";
     }
     $view->setLayout("product_" . $product->product_template);
     $_review = JTable::getInstance('review', 'jshop');
     if (($allow_review = $_review->getAllowReview()) > 0) {
         $arr_marks = array();
         $arr_marks[] = JHTML::_('select.option', '0', _JSHOP_NOT, 'mark_id', 'mark_value');
         for ($i = 1; $i <= $jshopConfig->max_mark; $i++) {
             $arr_marks[] = JHTML::_('select.option', $i, $i, 'mark_id', 'mark_value');
         }
         $text_review = '';
         $select_review = JHTML::_('select.genericlist', $arr_marks, 'mark', 'class="inputbox" size="1"', 'mark_id', 'mark_value');
     } else {
         $select_review = '';
         $text_review = $_review->getText();
     }
     if ($allow_review) {
         JSFactory::loadJsFilesRating();
     }
     if ($jshopConfig->product_show_manufacturer_logo || $jshopConfig->product_show_manufacturer) {
         $product->manufacturer_info = $product->getManufacturerInfo();
         if (!isset($product->manufacturer_info)) {
             $product->manufacturer_info = new stdClass();
             $product->manufacturer_info->manufacturer_logo = '';
             $product->manufacturer_info->name = '';
         }
     } else {
         $product->manufacturer_info = new stdClass();
         $product->manufacturer_info->manufacturer_logo = '';
         $product->manufacturer_info->name = '';
     }
     if ($jshopConfig->product_show_vendor) {
         $vendorinfo = $product->getVendorInfo();
         $vendorinfo->urllistproducts = SEFLink("index.php?option=com_jshopping&controller=vendor&task=products&vendor_id=" . $vendorinfo->id, 1);
         $vendorinfo->urlinfo = SEFLink("index.php?option=com_jshopping&controller=vendor&task=info&vendor_id=" . $vendorinfo->id, 1);
         $product->vendor_info = $vendorinfo;
     } else {
         $product->vendor_info = null;
     }
     if ($jshopConfig->admin_show_product_extra_field) {
         $product->extra_field = $product->getExtraFields();
     } else {
         $product->extra_field = null;
     }
     if ($jshopConfig->admin_show_freeattributes) {
         $product->getListFreeAttributes();
         foreach ($product->freeattributes as $k => $v) {
             if (!isset($back_value['freeattr'][$v->id])) {
                 $back_value['freeattr'][$v->id] = '';
             }
             $product->freeattributes[$k]->input_field = '<input type="text" class="inputbox" size="40" name="freeattribut[' . $v->id . ']" value="' . $back_value['freeattr'][$v->id] . '" />';
         }
         $attrrequire = $product->getRequireFreeAttribute();
         $product->freeattribrequire = count($attrrequire);
     } else {
         $product->freeattributes = null;
         $product->freeattribrequire = 0;
     }
     if ($jshopConfig->product_show_qty_stock) {
         $product->qty_in_stock = getDataProductQtyInStock($product);
     }
     if (!$jshopConfig->admin_show_product_labels) {
         $product->label_id = null;
     }
     if ($product->label_id) {
         $image = getNameImageLabel($product->label_id);
         if ($image) {
             $product->_label_image = $jshopConfig->image_labels_live_path . "/" . $image;
         }
         $product->_label_name = getNameImageLabel($product->label_id, 2);
     }
     $hide_buy = 0;
     if ($jshopConfig->user_as_catalog) {
         $hide_buy = 1;
     }
     if ($jshopConfig->hide_buy_not_avaible_stock && $product->product_quantity <= 0) {
         $hide_buy = 1;
     }
     $available = "";
     if ($product->getQty() <= 0 && $product->product_quantity > 0) {
         $available = _JSHOP_PRODUCT_NOT_AVAILABLE_THIS_OPTION;
     } elseif ($product->product_quantity <= 0) {
         $available = _JSHOP_PRODUCT_NOT_AVAILABLE;
     }
     $product->_display_price = getDisplayPriceForProduct($product->getPriceCalculate());
     if (!$product->_display_price) {
         $product->product_old_price = 0;
         $product->product_price_default = 0;
         $product->product_basic_price_show = 0;
         $product->product_is_add_price = 0;
         $product->product_tax = 0;
         $jshopConfig->show_plus_shipping_in_product = 0;
     }
     if (!$product->_display_price) {
         $hide_buy = 1;
     }
     $default_count_product = 1;
     if ($jshopConfig->min_count_order_one_product > 1) {
         $default_count_product = $jshopConfig->min_count_order_one_product;
     }
     if ($back_value['qty']) {
         $default_count_product = $back_value['qty'];
     }
     if (trim($product->description) == "") {
         $product->description = $product->short_description;
     }
     if ($jshopConfig->use_plugin_content) {
         changeDataUsePluginContent($product, "product");
     }
     $product->button_back_js_click = "history.go(-1);";
     if ($session->get('jshop_end_page_list_product') && $jshopConfig->product_button_back_use_end_list) {
         $product->button_back_js_click = "location.href='" . $session->get('jshop_end_page_list_product') . "';";
     }
     $displaybuttons = '';
     if ($jshopConfig->hide_buy_not_avaible_stock && $product->getQty() <= 0) {
         $displaybuttons = 'display:none;';
     }
     $product_images = $product->getImages();
     $product_videos = $product->getVideos();
     $product_demofiles = $product->getDemoFiles();
     $dispatcher->trigger('onBeforeDisplayProductList', array(&$product->product_related));
     $dispatcher->trigger('onBeforeDisplayProduct', array(&$product, &$view, &$product_images, &$product_videos, &$product_demofiles));
     $view->assign('config', $jshopConfig);
     $view->assign('image_path', $jshopConfig->live_path . '/images');
     $view->assign('noimage', $jshopConfig->noimage);
     $view->assign('image_product_path', $jshopConfig->image_product_live_path);
     $view->assign('video_product_path', $jshopConfig->video_product_live_path);
     $view->assign('video_image_preview_path', $jshopConfig->video_product_live_path);
     $view->assign('product', $product);
     $view->assign('category_id', $category_id);
     $view->assign('images', $product_images);
     $view->assign('videos', $product_videos);
     $view->assign('demofiles', $product_demofiles);
     $view->assign('attributes', $attributes);
     $view->assign('all_attr_values', $all_attr_values);
     $view->assign('related_prod', $product->product_related);
     $view->assign('path_to_image', $jshopConfig->live_path . 'images/');
     $view->assign('live_path', JURI::root());
     $view->assign('enable_wishlist', $jshopConfig->enable_wishlist);
     $view->assign('action', SEFLink('index.php?option=com_jshopping&controller=cart&task=add', 1));
     $view->assign('urlupdateprice', SEFLink('index.php?option=com_jshopping&controller=product&task=ajax_attrib_select_and_price&product_id=' . $product_id . '&ajax=1', 1, 1));
     if ($allow_review) {
         $context = "jshoping.list.front.product.review";
         $limit = $mainframe->getUserStateFromRequest($context . 'limit', 'limit', 20, 'int');
         $limitstart = JRequest::getInt('limitstart');
         $total = $product->getReviewsCount();
         $view->assign('reviews', $product->getReviews($limitstart, $limit));
         jimport('joomla.html.pagination');
         $pagination = new JPagination($total, $limitstart, $limit);
         $pagenav = $pagination->getPagesLinks();
         $view->assign('pagination', $pagenav);
         $view->assign('pagination_obj', $pagination);
         $view->assign('display_pagination', $pagenav != "");
     }
     $view->assign('allow_review', $allow_review);
     $view->assign('select_review', $select_review);
     $view->assign('text_review', $text_review);
     $view->assign('stars_count', floor($jshopConfig->max_mark / $jshopConfig->rating_starparts));
     $view->assign('parts_count', $jshopConfig->rating_starparts);
     $view->assign('user', $user);
     $view->assign('shippinginfo', SEFLink('index.php?option=com_jshopping&controller=content&task=view&page=shipping', 1));
     $view->assign('hide_buy', $hide_buy);
     $view->assign('available', $available);
     $view->assign('default_count_product', $default_count_product);
     $view->assign('folder_list_products', "list_products");
     $view->assign('back_value', $back_value);
     $view->assign('displaybuttons', $displaybuttons);
     $dispatcher->trigger('onBeforeDisplayProductView', array(&$view));
     $view->display();
     $dispatcher->trigger('onAfterDisplayProduct', array(&$product));
     if ($ajax) {
         die;
     }
 }
예제 #5
0
 public static function product($category, $product)
 {
     $Itemid = JRequest::getInt('Itemid');
     if (getShopMainPageItemid() == $Itemid) {
         appendExtendPathway($category->getTreeChild(), 'product');
     }
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $menuItem = $menu->getItem($Itemid);
     if ($menuItem->query['view'] != 'product') {
         appendPathWay($product->name);
     }
     if ($product->meta_title == "") {
         $product->meta_title = $product->name;
     }
     setMetaData($product->meta_title, $product->meta_keyword, $product->meta_description);
 }
예제 #6
0
 function _updateStatus($order_id, $order_status, $status_id, $notify, $comments, $include, $view_order)
 {
     $mainframe = JFactory::getApplication();
     $jshopConfig = JSFactory::getConfig();
     $client_id = JRequest::getInt('client_id', 0);
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeChangeOrderStatusAdmin', array(&$order_id, &$order_status, &$status_id, &$notify, &$comments, &$include, &$view_order));
     $order = JSFactory::getTable('order', 'jshop');
     $order->load($order_id);
     JSFactory::loadLanguageFile($order->getLang());
     $prev_order_status = $order->order_status;
     $order->order_status = $order_status;
     $order->order_m_date = getJsDate();
     $order->store();
     $vendorinfo = $order->getVendorInfo();
     if ($jshopConfig->order_stock_removed_only_paid_status) {
         $product_stock_removed = in_array($order_status, $jshopConfig->payment_status_enable_download_sale_file);
     } else {
         $product_stock_removed = !in_array($order_status, $jshopConfig->payment_status_return_product_in_stock);
     }
     if (!$product_stock_removed && $order->product_stock_removed == 1) {
         $order->changeProductQTYinStock("+");
     }
     if ($product_stock_removed && $order->product_stock_removed == 0) {
         $order->changeProductQTYinStock("-");
     }
     $order_history = JSFactory::getTable('orderHistory', 'jshop');
     $order_history->order_id = $order_id;
     $order_history->order_status_id = $order_status;
     $order_history->status_date_added = getJsDate();
     $order_history->customer_notify = $notify;
     $order_history->comments = $comments;
     $order_history->store();
     if ($jshopConfig->admin_show_vendors) {
         $listVendors = $order->getVendors();
     } else {
         $listVendors = array();
     }
     $vendors_send_message = $jshopConfig->vendor_order_message_type == 1 || $order->vendor_type == 1 && $jshopConfig->vendor_order_message_type == 2;
     $vendor_send_order = $jshopConfig->vendor_order_message_type == 2 && $order->vendor_type == 0 && $order->vendor_id;
     if ($jshopConfig->vendor_order_message_type == 3) {
         $vendor_send_order = 1;
     }
     $admin_send_order = 1;
     if ($jshopConfig->admin_not_send_email_order_vendor_order && $vendor_send_order && count($listVendors)) {
         $admin_send_order = 0;
     }
     $lang = JSFactory::getLang($order->getLang());
     $new_status = JSFactory::getTable('orderStatus', 'jshop');
     $new_status->load($order_status);
     $comments = $include ? $comments : '';
     $name = $lang->get('name');
     $shop_item_id = getShopMainPageItemid();
     $juri = JURI::getInstance();
     $liveurlhost = $juri->toString(array("scheme", 'host', 'port'));
     $app = JApplication::getInstance('site');
     $router = $app->getRouter();
     $uri = $router->build('index.php?option=com_jshopping&controller=user&task=order&order_id=' . $order_id . "&Itemid=" . $shop_item_id);
     $url = $uri->toString();
     $order_details_url = $liveurlhost . str_replace('/administrator', '', $url);
     if ($order->user_id == -1) {
         $order_details_url = '';
     }
     $mailfrom = $mainframe->getCfg('mailfrom');
     $fromname = $mainframe->getCfg('fromname');
     JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_jshopping/models');
     $checkout = JSFactory::getModel('checkout', 'jshop');
     $message = $checkout->getMessageChangeStatusOrder($order, $new_status->{$name}, $vendorinfo, $order_details_url, $comments);
     //message client
     if ($notify) {
         $ishtml = false;
         $subject = sprintf(_JSHOP_ORDER_STATUS_CHANGE_SUBJECT, $order->order_number);
         $dispatcher->trigger('onBeforeSendClientMailOrderStatus', array(&$message, &$order, &$comments, &$new_status, &$vendorinfo, &$order_details_url, &$ishtml, &$mailfrom, &$fromname, &$subject));
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->addRecipient($order->email);
         $mailer->setSubject($subject);
         $mailer->setBody($message);
         $mailer->isHTML($ishtml);
         $send = $mailer->Send();
     }
     //message vendors
     if ($vendors_send_message || $vendor_send_order) {
         $subject = sprintf(_JSHOP_ORDER_STATUS_CHANGE_SUBJECT, $order->order_number);
         foreach ($listVendors as $k => $datavendor) {
             $ishtml = false;
             $dispatcher->trigger('onBeforeSendVendorMailOrderStatus', array(&$message, &$order, &$comments, &$new_status, &$vendorinfo, &$order_details_url, &$ishtml, &$mailfrom, &$fromname, &$subject, &$datavendor));
             $mailer = JFactory::getMailer();
             $mailer->setSender(array($mailfrom, $fromname));
             $mailer->addRecipient($datavendor->email);
             $mailer->setSubject($subject);
             $mailer->setBody($message);
             $mailer->isHTML($ishtml);
             $send = $mailer->Send();
         }
     }
     JSFactory::loadAdminLanguageFile();
     $dispatcher->trigger('onAfterChangeOrderStatusAdmin', array(&$order_id, &$order_status, &$status_id, &$notify, &$comments, &$include, &$view_order));
     if ($view_order) {
         $this->setRedirect("index.php?option=com_jshopping&controller=orders&task=show&order_id=" . $order_id, _JSHOP_ORDER_STATUS_CHANGED);
     } else {
         $this->setRedirect("index.php?option=com_jshopping&controller=orders&client_id=" . $client_id, _JSHOP_ORDER_STATUS_CHANGED);
     }
 }
예제 #7
0
 function view()
 {
     $mainframe = JFactory::getApplication();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $jshopConfig = JSFactory::getConfig();
     $session = JFactory::getSession();
     $session->set("jshop_end_page_buy_product", $_SERVER['REQUEST_URI']);
     $session->set("jshop_end_page_list_product", $_SERVER['REQUEST_URI']);
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onBeforeLoadProductList', array());
     $category_id = JRequest::getInt('category_id');
     $category = JSFactory::getTable('category', 'jshop');
     $category->load($category_id);
     $category->getDescription();
     $dispatcher->trigger('onAfterLoadCategory', array(&$category, &$user));
     if (!$category->category_id || $category->category_publish == 0 || !in_array($category->access, $user->getAuthorisedViewLevels())) {
         JError::raiseError(404, _JSHOP_PAGE_NOT_FOUND);
         return;
     }
     $manufacturer_id = JRequest::getInt('manufacturer_id');
     $label_id = JRequest::getInt('label_id');
     $vendor_id = JRequest::getInt('vendor_id');
     $view_name = "category";
     $view_config = array("template_path" => $jshopConfig->template_path . $jshopConfig->template . "/" . $view_name);
     $view = $this->getView($view_name, getDocumentType(), '', $view_config);
     if ($category->category_template == "") {
         $category->category_template = "default";
     }
     $view->setLayout("category_" . $category->category_template);
     $jshopConfig->count_products_to_page = $category->products_page;
     $context = "jshoping.list.front.product";
     $contextfilter = "jshoping.list.front.product.cat." . $category_id;
     $orderby = $mainframe->getUserStateFromRequest($context . 'orderby', 'orderby', $jshopConfig->product_sorting_direction, 'int');
     $order = $mainframe->getUserStateFromRequest($context . 'order', 'order', $jshopConfig->product_sorting, 'int');
     $limit = $mainframe->getUserStateFromRequest($context . 'limit', 'limit', $category->products_page, 'int');
     if (!$limit) {
         $limit = $category->products_page;
     }
     $limitstart = JRequest::getInt('limitstart');
     $orderbyq = getQuerySortDirection($order, $orderby);
     $image_sort_dir = getImgSortDirection($order, $orderby);
     $field_order = $jshopConfig->sorting_products_field_select[$order];
     $filters = getBuildFilterListProduct($contextfilter, array("categorys"));
     if (getShopMainPageItemid() == JRequest::getInt('Itemid')) {
         appendExtendPathWay($category->getTreeChild(), 'category');
     }
     $orderfield = $jshopConfig->category_sorting == 1 ? "ordering" : "name";
     $sub_categories = $category->getChildCategories($orderfield, 'asc', $publish = 1);
     $dispatcher->trigger('onBeforeDisplayCategory', array(&$category, &$sub_categories));
     if ($category->meta_title == "") {
         $category->meta_title = $category->name;
     }
     setMetaData($category->meta_title, $category->meta_keyword, $category->meta_description);
     $total = $category->getCountProducts($filters);
     $action = xhtmlUrl($_SERVER['REQUEST_URI']);
     $dispatcher->trigger('onBeforeFixLimitstartDisplayProductList', array(&$limitstart, &$total, 'category'));
     if ($limitstart >= $total) {
         $limitstart = 0;
     }
     $products = $category->getProducts($filters, $field_order, $orderbyq, $limitstart, $limit);
     addLinkToProducts($products, $category_id);
     jimport('joomla.html.pagination');
     $pagination = new JPagination($total, $limitstart, $limit);
     $pagenav = $pagination->getPagesLinks();
     foreach ($jshopConfig->sorting_products_name_select as $key => $value) {
         $sorts[] = JHTML::_('select.option', $key, $value, 'sort_id', 'sort_value');
     }
     insertValueInArray($category->products_page, $jshopConfig->count_product_select);
     //insert category count
     foreach ($jshopConfig->count_product_select as $key => $value) {
         $product_count[] = JHTML::_('select.option', $key, $value, 'count_id', 'count_value');
     }
     $sorting_sel = JHTML::_('select.genericlist', $sorts, 'order', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"', 'sort_id', 'sort_value', $order);
     $product_count_sel = JHTML::_('select.genericlist', $product_count, 'limit', 'class = "inputbox" size = "1" onchange = "submitListProductFilters()"', 'count_id', 'count_value', $limit);
     $_review = JSFactory::getTable('review', 'jshop');
     $allow_review = $_review->getAllowReview();
     if (!$category->category_ordertype) {
         $category->category_ordertype = 1;
     }
     $manufacuturers_sel = '';
     if ($jshopConfig->show_product_list_filters) {
         $filter_manufactures = $category->getManufacturers();
         $first_manufacturer = array();
         $first_manufacturer[] = JHTML::_('select.option', 0, _JSHOP_ALL, 'id', 'name');
         $manufacuturers_sel = JHTML::_('select.genericlist', array_merge($first_manufacturer, $filter_manufactures), 'manufacturers[]', 'class = "inputbox" onchange = "submitListProductFilters()"', 'id', 'name', $filters['manufacturers'][0]);
     }
     if ($jshopConfig->use_plugin_content) {
         changeDataUsePluginContent($category, "category");
     }
     $willBeUseFilter = willBeUseFilter($filters);
     $display_list_products = count($products) > 0 || $willBeUseFilter;
     $dispatcher->trigger('onBeforeDisplayProductList', array(&$products));
     $view->assign('config', $jshopConfig);
     $view->assign('template_block_list_product', "list_products/list_products.php");
     $view->assign('template_no_list_product', "list_products/no_products.php");
     $view->assign('template_block_form_filter', "list_products/form_filters.php");
     $view->assign('template_block_pagination', "list_products/block_pagination.php");
     $view->assign('path_image_sorting_dir', $jshopConfig->live_path . 'images/' . $image_sort_dir);
     $view->assign('filter_show', 1);
     $view->assign('filter_show_category', 0);
     $view->assign('filter_show_manufacturer', 1);
     $view->assign('pagination', $pagenav);
     $view->assign('pagination_obj', $pagination);
     $view->assign('display_pagination', $pagenav != "");
     $view->assign('rows', $products);
     $view->assign('count_product_to_row', $category->products_row);
     $view->assign('image_category_path', $jshopConfig->image_category_live_path);
     $view->assign('noimage', $jshopConfig->noimage);
     $view->assign('category', $category);
     $view->assign('categories', $sub_categories);
     $view->assign('count_category_to_row', $jshopConfig->count_category_to_row);
     $view->assign('allow_review', $allow_review);
     $view->assign('product_count', $product_count_sel);
     $view->assign('sorting', $sorting_sel);
     $view->assign('action', $action);
     $view->assign('orderby', $orderby);
     $view->assign('manufacuturers_sel', $manufacuturers_sel);
     $view->assign('filters', $filters);
     $view->assign('willBeUseFilter', $willBeUseFilter);
     $view->assign('display_list_products', $display_list_products);
     $view->assign('shippinginfo', SEFLink($jshopConfig->shippinginfourl, 1));
     $dispatcher->trigger('onBeforeDisplayProductListView', array(&$view));
     $view->display();
 }
예제 #8
0
 public static function product($category, $product)
 {
     if (getShopMainPageItemid() == JRequest::getInt('Itemid')) {
         appendExtendPathway($category->getTreeChild(), 'product');
     }
     appendPathWay($product->name);
     if ($product->meta_title == "") {
         $product->meta_title = $product->name;
     }
     setMetaData($product->meta_title, $product->meta_keyword, $product->meta_description);
 }