public function update() { if ($this->viewAccess() && JeproshopTools::checkCategoryToken()) { $app = JFactory::getApplication(); $category_id = $app->input->get('category_id'); if (isset($category_id) && $category_id > 0) { $categoryModel = new JeproshopCategoryModelCategory($category_id); $categoryModel->updateCategory(); } } }
public function addShop($tpl = null) { if ($this->context == null) { $this->context = JeproshopContext::getContext(); } $display_group_list = true; if ($display_group_list) { $shop_groups = JeproshopShopGroupModelShopGroup::getShopGroups(); $this->assignRef('shop_groups', $shop_groups); } $categories = JeproshopCategoryModelCategory::getRootCategories($this->context->language->lang_id); $themes = JeproshopThemeModelTheme::getThemes(); $this->assignRef('themes', $themes); $this->assignRef('categories', $categories); $this->addToolBar(); $this->sideBar = JHtmlSidebar::render(); parent::display($tpl); }
/** * Get the user's journey * * @param integer $category_id Category ID * @param string $path Path end * @param bool $link_on_the_item * @param string $category_type * @param JeproshopContext $context * @return string * @internal param bool $linkOnTheLastItem Put or not a link on the current category * @internal param $string [optional] $categoryType defined what type of categories is used (products or cms) */ public static function getPath($category_id, $path = '', $link_on_the_item = false, $category_type = 'products', JeproshopContext $context = null) { if (!$context) { $context = JeproshopContext::getContext(); } $category_id = (int) $category_id; if ($category_id == 1) { return '<span class="navigation_end">' . $path . '</span>'; } $pipe = '>'; //Configuration::get('PS_NAVIGATION_PIPE'); if (empty($pipe)) { $pipe = '>'; } $full_path = ''; if ($category_type === 'products') { $interval = JeproshopCategoryModelCategory::getInterval($category_id); $root_category_id = $context->shop->getCategoryId(); $interval_root = JeproshopCategoryModelCategory::getInterval($root_category_id); $db = JFactory::getDBO(); if ($interval) { $query = "SELECT category.category_id, category_lang.name, category_lang.link_rewrite FROM " . $db->quoteName('#__jeproshop_category'); $query .= " AS category LEFT JOIN " . $db->quoteName('#__jeproshop_category_lang') . " AS category_lang ON (category_lang.category_id ="; $query .= "category.category_id" . JeproshopShopModelShop::addSqlRestrictionOnLang('category_lang') . ")" . JeproshopShopModelShop::addSqlAssociation('category'); $query .= "\tWHERE category.n_left <= " . $interval->n_left . " AND category.n_right >= " . $interval->n_right . "\tAND category.n_left >= "; $query .= $interval_root->n_left . " AND category.n_right <= " . $interval_root->n_right . " AND category_lang.lang_id = " . (int) $context->language->lang_id; $query .= "\tAND category.published = 1 AND category.depth_level > " . (int) $interval_root->depth_level . " ORDER BY category.depth_level ASC"; $db->setQuery($query); $categories = $db->loadObjectList(); $n = 1; $n_categories = count($categories); foreach ($categories as $category) { $full_path .= ($n < $n_categories || $link_on_the_item ? '<a href="' . JeproshopTools::safeOutput($context->controller->getCategoryLink((int) $category->category_id, $category->link_rewrite)) . '" title="' . htmlentities($category->name, ENT_NOQUOTES, 'UTF-8') . '">' : '') . htmlentities($category->name, ENT_NOQUOTES, 'UTF-8') . ($n < $n_categories || $link_on_the_item ? '</a>' : '') . ($n++ != $n_categories || !empty($path) ? '<span class="navigation-pipe">' . $pipe . '</span>' : ''); } return $full_path . $path; } } else { if ($category_type === 'CMS') { $category = new CMSCategory($category_id, $context->language->id); if (!Validate::isLoadedObject($category)) { die(Tools::displayError()); } $category_link = $context->link->getCMSCategoryLink($category); if ($path != $category->name) { $full_path .= '<a href="' . Tools::safeOutput($category_link) . '">' . htmlentities($category->name, ENT_NOQUOTES, 'UTF-8') . '</a><span class="navigation-pipe">' . $pipe . '</span>' . $path; } else { $full_path = ($link_on_the_item ? '<a href="' . Tools::safeOutput($category_link) . '">' : '') . htmlentities($path, ENT_NOQUOTES, 'UTF-8') . ($link_on_the_item ? '</a>' : ''); } return Tools::getPath($category->parent_id, $full_path, $link_on_the_item, $category_type); } } }
public function renderEditForm($tpl = null) { $this->loadObject(true); $app = JFactory::getApplication(); if (!isset($this->context)) { $this->context = JeproshopContext::getContext(); } $shop_id = JeproshopContext::getContext()->shop->shop_id; $selected_categories = array(isset($this->context->controller->category->parent_id) && $this->context->controller->category->isParentCategoryAvailable($shop_id) ? (int) $this->context->controller->category->parent_id : $app->input->get('parent_id', JeproshopCategoryModelCategory::getRootCategory()->category_id)); $unidentified = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('unidentified_group')); $guest = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('guest_group')); $default = new JeproshopGroupModelGroup(JeproshopSettingModelSetting::getValue('customer_group')); $unidentified_group_information = '<b>' . $unidentified->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_ALL_PEOPLE_WITHOUT_A_VALID_CUSTOMER_ACCOUNT_MESSAGE'); $guest_group_information = '<b>' . $guest->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_CUSTOMER_WHO_PLACED_AN_ORDER_WITH_THE_GUEST_CHECKOUT_MESSAGE'); $default_group_information = '<b>' . $default->name[$this->context->language->lang_id] . '</b> ' . JText::_('COM_JEPROSHOP_ALL_PEOPLE_WHO_HAVE_CREATED_AN_CREATED_AN_ACCOUNT_ON_THIS_SITE_MESSAGE'); $this->assignRef('unidentified_group_information', $unidentified_group_information); $this->assignRef('guest_group_information', $guest_group_information); $this->assignRef('default_group_information', $default_group_information); $image = COM_JEPROSHOP_CATEGORY_IMAGE_DIR . $this->context->controller->category->category_id . '.jpg'; $image_url = JeproshopImageManager::thumbnail($image, 'category_' . $this->context->controller->category->category_id . '.jpg', 350, 'jpg', true, true); $imageSize = file_exists($image) ? filesize($image) / 1000 : false; $shared_category = JeproshopTools::isLoadedObject($this->context->controller->category, 'category_id') && $this->context->controller->category->hasMultishopEntries(); $this->assignRef('shared_category', $shared_category); $allow_accented_chars_url = (int) JeproshopSettingModelSetting::getValue('allow_accented_chars_url'); $this->assignRef('allow_accented_chars_url', $allow_accented_chars_url); //$this->assignRef('selected_categories', $selected_categories); $categories_tree = new JeproshopCategoriesTree('jform_categories_tree', JText::_('COM_JEPROSHOP_CATEGORIES_LABEL'), null, $this->context->language->lang_id); $categories_tree->setTreeTemplate('associated_categories')->setSelectedCategories($selected_categories)->setUseCheckBox(true)->setInputName('parent_id'); $categories_data = $categories_tree->render(); $this->assignRef('categories_tree', $categories_data); $image = JeproshopImageManager::thumbnail(COM_JEPROSHOP_CATEGORY_IMAGE_DIR . '/' . $this->context->controller->category->category_id . '.jpg', 'category_' . (int) $this->context->controller->category->category_id . '.jpg', 350, 'jpg', true); $this->assignRef('image', $image ? $image : false); $size = $image ? filesize(COM_JEPROSHOP_CATEGORY_IMAGE_DIR . '/' . $this->context->controller->category->category_id . 'jpg') / 1000 : false; $this->assignRef('size', $size); $category_group_ids = $this->context->controller->category->getGroups(); $groups = JeproshopGroupModelGroup::getGroups($this->context->language->lang_id); //if empty $carrier_groups_ids : object creation : we set the default groups if (empty($category_group_ids)) { $preSelected = array(JeproshopSettingModelSetting::getValue('unidentified_group'), JeproshopSettingModelSetting::getValue('guest_group'), JeproshopSettingModelSetting::getValue('customer_group')); $category_group_ids = array_merge($category_group_ids, $preSelected); } foreach ($groups as $group) { $groupBox = $app->input->get('group_box_' . $group->group_id, in_array($group->group_id, $category_group_ids)); $this->assignRef('group_box_' . $group->group_id, $groupBox); } $is_root_category = (bool) $app->input->get('is_root_category'); $this->assignRef('is_root_category', $is_root_category); $helper = new JeproshopHelper(); $this->assignRef('helper', $helper); $this->assignRef('groups', $groups); $this->addToolBar(); $this->sideBar = JHtmlSideBar::render(); parent::display($tpl); }
public static function getProductProperties($lang_id, $row, JeproshopContext $context = null) { if (!$row->product_id) { return false; } if ($context == null) { $context = JeproshopContext::getContext(); } // Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it: // consider adding it in order to avoid unnecessary queries $row->allow_out_of_stock_ordering = JeproshopProductModelProduct::isAvailableWhenOutOfStock($row->out_of_stock); if (JeproshopCombinationModelCombination::isFeaturePublished() && (!isset($row->product_attribute_id) || !$row->product_attribute_id) && (isset($row->cache_default_attribute) && ($default_product_attribute_id = $row->cache_default_attribute) !== null || ($default_product_attribute_id = JeproshopProductModelProduct::getDefaultAttribute($row->product_id, !$row->allow_out_of_stock_ordering)))) { $row->product_attribute_id = $default_product_attribute_id; } if (!JeproshopCombinationModelCombination::isFeaturePublished() || !isset($row->product_attribute_id)) { $row->product_attribute_id = 0; } // Tax $useTax = JeproshopTaxModelTax::taxExcludedOption(); $cache_key = $row->product_id . '_' . $row->product_attribute_id . '_' . $lang_id . '_' . (int) $useTax; if (isset($row->product_pack_id)) { $cache_key .= '_pack_' . $row->product_pack_id; } if (isset(self::$_productPropertiesCache[$cache_key])) { return JeproshopTools::updateObjectData($row, self::$_productPropertiesCache[$cache_key]); } // Datas $row->category = JeproshopCategoryModelCategory::getLinkRewrite((int) $row->default_category_id, (int) $lang_id); $row->link = $context->controller->getProductLink((int) $row->product_id, $row->link_rewrite, $row->category, $row->ean13); $row->attribute_price = 0; if (isset($row->product_attribute_id) && $row->product_attribute_id) { $row->attribute_price = (double) JeproshopProductModelProduct::getProductAttributePrice($row->product_attribute_id); } $row->price_tax_exc = JeproshopProductModelProduct::getStaticPrice((int) $row->product_id, false, isset($row->product_attribute_id) && !empty($row->product_attribute_id) ? (int) $row->product_attribute_id : null, self::$_taxCalculationMethod == COM_JEPROSHOP_TAX_EXCLUDED ? 2 : 6); if (self::$_taxCalculationMethod == COM_JEPROSHOP_TAX_EXCLUDED) { $row->price_tax_exc = JeproshopTools::roundPrice($row->price_tax_exc, 2); $row->price = JeproshopProductModelProduct::getStaticPrice((int) $row->product_id, true, isset($row->product_attribute_id) && !empty($row->product_attribute_id) ? (int) $row->product_attribute_id : null, 6); $row->price_without_reduction = JeproshopProductModelProduct::getStaticPrice((int) $row->product_id, false, isset($row->product_attribute_id) && !empty($row->product_attribute_id) ? (int) $row->product_attribute_id : null, 2, null, false, false); } else { $row->price = JeproshopTools::roundPrice(JeproshopProductModelProduct::getStaticPrice((int) $row->product_id, true, isset($row->product_attribute_id) && !empty($row->product_attribute_id) ? (int) $row->product_attribute_id : null, 2), 2); $row->price_without_reduction = JeproshopProductModelProduct::getStaticPrice((int) $row->product_id, true, isset($row->product_attribute_id) && !empty($row->product_attribute_id) ? (int) $row->product_attribute_id : null, 6, null, false, false); } $specific_prices = null; $row->reduction = JeproshopProductModelProduct::getStaticPrice((int) $row->product_id, (bool) $useTax, (int) $row->product_attribute_id, 6, null, true, true, 1, true, null, null, null, $specific_prices); $row->specific_prices = $specific_prices; $row->quantity = JeproshopProductModelProduct::getQuantity((int) $row->product_id, 0, isset($row->cache_is_pack) ? $row->cache_is_pack : null); $row->quantity_all_versions = $row->quantity; if ($row->product_attribute_id) { $row->quantity = JeproshopProductModelProduct::getQuantity((int) $row->product_id, $row->product_attribute_id, isset($row->cache_is_pack) ? $row->cache_is_pack : null); } $row->image_id = JeproshopProductModelProduct::defineProductImage($row, $lang_id); $row->features = JeproshopProductModelProduct::getFrontStaticFeatures((int) $lang_id, $row->product_id); $row->attachments = array(); if (!isset($row->cache_has_attachments) || $row->cache_has_attachments) { $row->attachments = JeproshopProductModelProduct::getStaticAttachments((int) $lang_id, $row->product_id); } $row->virtual = !isset($row->is_virtual) || $row->is_virtual ? 1 : 0; // Pack management $row->pack = !isset($row->cache_is_pack) ? JeproshopProductPack::isPack($row->product_id) : (int) $row->cache_is_pack; $row->packItems = $row->pack ? JeproshopProductPack::getItemTable($row->product_id, $lang_id) : array(); $row->no_pack_price = $row->pack ? JeproshopProductPack::noPackPrice($row->product_id) : 0; if ($row->pack && !JeproshopProductPack::isInStock($row->product_id)) { $row->quantity = 0; } $row->customization_required = false; if (isset($row->customizable) && $row->customizable && JeproshopCustomization::isFeaturePublished()) { if (count(JeproshopProductModelProduct::getStaticRequiredCustomizableFields((int) $row->product_id))) { $row->customization_required = true; } } $row = JeproshopProductModelProduct::getTaxesInformations($row, $context); self::$_productPropertiesCache[$cache_key] = $row; return self::$_productPropertiesCache[$cache_key]; }
/** * Check if current category is a child of shop root category * * @param JeproshopShopModelShop $shop * @return bool */ public function inShop(JeproshopShopModelShop $shop = null) { if (!$shop) { $shop = JeproshopContext::getContext()->shop; } if (!($interval = JeproshopCategoryModelCategory::getInterval($shop->getCategoryId()))) { return false; } return $this->n_left >= $interval->n_left && $this->n_right <= $interval->n_right; }
public function renderView($tpl = null) { if ($this->getLayout() !== 'modal') { } if ($this->context == null) { $this->context = JeproshopContext::getContext(); } $db = JFactory::getDBO(); $this->setLayout('view'); $this->loadObject(); if (!JeproshopTools::isLoadedObject($this->customer, 'customer_id')) { return; } $this->context->customer = $this->customer; $customer_stats = $this->customer->getStats(); $query = "SELECT SUM(total_paid_real) FROM " . $db->quoteName('#__jeproshop_orders'); $query .= " WHERE customer_id = " . (int) $this->customer->customer_id . " AND valid = 1"; $db->setQuery($query); $total_customer = $db->loadResult(); if ($total_customer) { $query = "SELECT SQL_CALC_FOUND_ROWS COUNT(*) FROM " . $db->quoteName('#__jeproshop_orders'); $query .= " WHERE valid = 1 AND customer_id != " . (int) $this->customer->customer_id . " GROUP BY "; $query .= "customer_id HAVING SUM(total_paid_real) > " . (int) $total_customer; $db->setQuery($query); $db->loadResult(); $count_better_customers = (int) $db->loadResult('SELECT FOUND_ROWS()') + 1; } else { $count_better_customers = '-'; } $orders = JeproshopOrderModelOrder::getCustomerOrders($this->customer->customer_id, true); $total_orders = count($orders); for ($i = 0; $i < $total_orders; $i++) { $orders[$i]->total_paid_real_not_formated = $orders[$i]->total_paid_real; $orders[$i]->total_paid_real = JeproshopTools::displayPrice($orders[$i]->total_paid_real, new JeproshopCurrencyModelCurrency((int) $orders[$i]->currency_id)); } $messages = JeproshopCustomerThreadModelCustomerThread::getCustomerMessages((int) $this->customer->customer_id); $total_messages = count($messages); for ($i = 0; $i < $total_messages; $i++) { $messages[$i]->message = substr(strip_tags(html_entity_decode($messages[$i]->message, ENT_NOQUOTES, 'UTF-8')), 0, 75); $messages[$i]->date_add = Tools::displayDate($messages[$i]->date_add, null, true); } $groups = $this->customer->getGroups(); $total_groups = count($groups); for ($i = 0; $i < $total_groups; $i++) { $group = new JeproshopGroupModelGroup($groups[$i]); $groups[$i] = array(); $groups[$i]['group_id'] = $group->group_id; $groups[$i]['name'] = $group->name[$this->context->controller->default_form_language]; } $total_ok = 0; $orders_ok = array(); $orders_ko = array(); foreach ($orders as $order) { if (!isset($order->order_state)) { $order->order_state = JText::_('COM_JEPROSHOP_THERE_IS_NO_STATUS_DEFINED_FOR_THIS_ORDER_MESSAGE'); } if ($order->valid) { $orders_ok[] = $order; $total_ok += $order->total_paid_real_not_formated; } else { $orders_ko[] = $order; } } $products = $this->customer->getBoughtProducts(); $carts = JeproshopCartModelCart::getCustomerCarts($this->customer->customer_id); $total_carts = count($carts); for ($i = 0; $i < $total_carts; $i++) { $cart = new JeproshopCartModelCart((int) $carts[$i]->cart_id); $this->context->cart = $cart; $summary = $cart->getSummaryDetails(); $currency = new JeproshopCurrencyModelCurrency((int) $carts[$i]->currency_id); $carrier = new JeproshopCarrierModelCarrier((int) $carts[$i]->carrier_id); $carts[$i]['id_cart'] = sprintf('%06d', $carts[$i]['id_cart']); $carts[$i]['date_add'] = JeproshopValidator::displayDate($carts[$i]->date_add, null, true); $carts[$i]['total_price'] = Tools::displayPrice($summary->total_price, $currency); $carts[$i]->name = $carrier->name; } $query = "SELECT DISTINCT cart_product.product_id, cart.cart_id, cart.shop_id, cart_product.shop_id "; $query .= " AS cart_product_shop_id FROM " . $db->quoteName('#__jeproshop_cart_product') . " AS cart_product"; $query .= " JOIN " . $db->quoteName('#__jeproshop_cart') . " AS cart ON (cart.cart_id = cart_product.cart_id) "; $query .= "JOIN " . $db->quoteName('#__jeproshop_product') . " AS product ON (cart_product.product_id = product."; $query .= "product_id) WHERE cart.customer_id = " . (int) $this->customer->customer_id . " AND cart_product.product_id"; $query .= " NOT IN ( SELECT product_id FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord JOIN "; $query .= $db->quoteName('#__jeproshop_order_detail') . " AS ord_detail ON (ord.order_id = ord_detail.order_id ) WHERE "; $query .= "ord.valid = 1 AND ord.customer_id = " . (int) $this->customer->customer_id . ")"; $db->setQuery($query); $interested = $db->loadObjectList(); $total_interested = count($interested); for ($i = 0; $i < $total_interested; $i++) { $product = new JeproshopProductModelProduct($interested[$i]->product_id, false, $this->context->controller->default_form_language, $interested[$i]->shop_id); if (!Validate::isLoadedObject($product, 'product_id')) { continue; } $interested[$i]->url = $this->context->controller->getProductLink($product->product_id, $product->link_rewrite, JeproshopCategoryModelCategory::getLinkRewrite($product->default_category_id, $this->context->controller->default_form_language), null, null, $interested[$i]->cp_shop_id); $interested[$i]->product_id = (int) $product->product_id; $interested[$i]->name = htmlentities($product->name); } $connections = $this->customer->getLastConnections(); if (!is_array($connections)) { $connections = array(); } $total_connections = count($connections); for ($i = 0; $i < $total_connections; $i++) { $connections[$i]->http_referer = $connections[$i]->http_referer ? preg_replace('/^www./', '', parse_url($connections[$i]->http_referer, PHP_URL_HOST)) : JText::_('COM_JEPROSHOP_DIRECT_LINK_LABEL'); } $referrers = JeproshopReferrerModelReferrer::getReferrers($this->customer->customer_id); $total_referrers = count($referrers); for ($i = 0; $i < $total_referrers; $i++) { $referrers[$i]->date_add = JeproshopTools::displayDate($referrers[$i]->date_add, null, true); } $customerLanguage = new JeproshopLanguageModelLanguage($this->customer->lang_id); $shop = new JeproshopShopModelShop($this->customer->shop_id); //$this->assignRef('customer', $customer); /*'gender' => $gender, /* 'gender_image' => $gender_image, // General information of the customer */ $registration = JeproshopTools::displayDate($this->customer->date_add, null, true); $this->assignRef('registration_date', $registration); $this->assignRef('customer_stats', $customer_stats); $last_visit = JeproshopTools::displayDate($customer_stats->last_visit, null, true); $this->assignRef('last_visit', $last_visit); $this->assignRef('count_better_customers', $count_better_customers); $shop_feature_active = JeproshopShopModelShop::isFeaturePublished(); $this->assignRef('shop_is_feature_active', $shop_feature_active); $this->assignRef('shop_name', $shop->shop_name); $customerBirthday = JeproshopTools::displayDate($this->customer->birthday); $this->assignRef('customer_birthday', $customerBirthday); $last_update = JeproshopTools::displayDate($this->customer->date_upd, null, true); $this->assignRef('last_update', $last_update); $customerExists = JeproshopCustomerModelCustomer::customerExists($this->customer->email); $this->assignRef('customer_exists', $customerExists); $this->assignRef('lang_id', $this->customer->lang_id); $this->assignRef('customerLanguage', $customerLanguage); // Add a Private note $customerNote = JeproshopTools::htmlentitiesUTF8($this->customer->note); $this->assignRef('customer_note', $customerNote); // Messages $this->assignRef('messages', $messages); // Groups $this->assignRef('groups', $groups); // Orders $this->assignRef('orders', $orders); $this->assignRef('orders_ok', $orders_ok); $this->assignRef('orders_ko', $orders_ko); $total_ok = JeproshopTools::displayPrice($total_ok, $this->context->currency->currency_id); $this->assignRef('total_ok', $total_ok); // Products $this->assignRef('products', $products); // Addresses $addresses = $this->customer->getAddresses($this->context->controller->default_form_language); $this->assignRef('addresses', $addresses); // Discounts $discounts = JeproshopCartRuleModelCartRule::getCustomerCartRules($this->context->controller->default_form_language, $this->customer->customer_id, false, false); $this->assignRef('discounts', $discounts); // Carts $this->assignRef('carts', $carts); // Interested $this->assignRef('interested_products', $interested); // Connections $this->assignRef('connections', $connections); // Referrers $this->assignRef('referrers', $referrers); if ($this->getLayout() != 'modal') { $this->addToolBar(); $this->sideBar = JHtmlSidebar::render(); } parent::display($tpl); }
/** * Assign template vars related to category */ protected function assignCategory() { // Assign category to the template if ($this->category !== false && JeproshopTools::isLoadedObject($this->category, 'category_id') && $this->category->inShop() && $this->category->isAssociatedToShop()) { $path = JeproshopTools::getPath($this->category->category_id, $this->product->name, true); } elseif (JeproshopCategoryModelCategory::inShopStatic($this->product->default_category_id, $this->context->shop)) { $this->category = new JeproshopCategoryModelCategory((int) $this->product->default_category_id, (int) $this->context->language->lang_id); if (JeproshopTools::isLoadedObject($this->category, 'category_id') && $this->category->published && $this->category->isAssociatedToShop()) { $path = JeproshopTools::getPath((int) $this->product->default_category_id, $this->product->name[$this->context->language->lang_id]); } } if (!isset($path) || !$path) { $path = JeproshopTools::getPath((int) $this->context->shop->category_id, $this->product->name[$this->context->language->lang_id]); } $subCategories = array(); if (JeproshopTools::isLoadedObject($this->category, 'category_id')) { $subCategories = $this->category->getSubCategories($this->context->language->lang_id, true); // various assignments before Hook::exec $this->assignRef('path', $path); $this->assignRef('category', $this->category); $this->assignRef('sub_categories', $subCategories); $this->assignRef('current_category_id', $this->category->category_id); $this->assignRef('parent_category_id', $this->category->parent_id); $return_category_name = JeproshopTools::safeOutput($this->category->getFieldByLang('name')); $this->assignRef('return_category_name', $return_category_name); $categories = JeproshopCategoryModelCategory::getHomeCategories($this->context->language->lang_id, true, (int) $this->context->shop->shop_id); $this->assignRef('categories', $categories); } //$this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('displayFooterProduct', array('product' => $this->product, 'category' => $this->category)))); }
public function getData() { if (!isset($this->data)) { $this->setTreeData(JeproshopCategoryModelCategory::getNestedCategories($this->getRootCategory(), $this->getLang(), false, null, $this->useShopRestriction())); } return $this->data; }
public static function recurseCategory($categories, $current, $category_id = 1, $selected_id = 1) { echo '<option value="' . $category_id . '"' . ($selected_id == $category_id ? ' selected="selected"' : '') . '>' . str_repeat(' ', $current['infos']['depth_level'] * 5) . stripslashes($current['infos']['name']) . '</option>'; if (isset($categories[$category_id])) { foreach (array_keys($categories[$category_id]) as $key) { JeproshopCategoryModelCategory::recurseCategory($categories, $categories[$category_id][$key], $key, $selected_id); } } }
private function addToolBar() { switch ($this->getLayout()) { case 'edit': JToolbarHelper::title(JText::_('COM_JEPROSHOP_PRODUCT_EDIT_PRODUCT_TITLE'), 'product-jeproshop'); JToolbarHelper::apply('update', JText::_('COM_JEPROSHOP_UPDATE_LABEL')); /*JToolbarHelper::custom('association', 'association.png', 'association.png', JText::_('COM_JEPROSHOP_SAVE_ASSOCIATION_LABEL'), true); JToolbarHelper::custom('price', 'price.png', 'price.png', JText::_('COM_JEPROSHOP_SAVE_PRICE_LABEL'), true); JToolbarHelper::custom('declination', 'declination.png', 'declination.png', JText::_('COM_JEPROSHOP_SAVE_DECLINATION_LABEL'), true); JToolbarHelper::custom('quantities', 'quantities.png', 'quantities.png', JText::_('COM_JEPROSHOP_SAVE_QUANTITIES_LABEL'), true); JToolbarHelper::custom('images', '.png', 'images.png', JText::_('COM_JEPROSHOP_SAVE_IMAGES_LABEL'), true); JToolbarHelper::custom('feature', 'features.png', 'features.png', JText::_('COM_JEPROSHOP_SAVE_FEATURES_LABEL'), true); JToolbarHelper::custom('customization', 'customization.png', 'customization.png', JText::_('COM_JEPROSHOP_SAVE_CUSTOMIZATION_LABEL'), true); JToolbarHelper::custom('attachment', 'attachment.png', 'attachment.png', JText::_('COM_JEPROSHOP_SAVE_ATTACHMENT_LABEL'), true); JToolbarHelper::custom('shipping', 'shipping.png', 'shipping.png', JText::_('COM_JEPROSHOP_SAVE_SHIPPING_LABEL'), true); JToolbarHelper::custom('supplier', 'supplier.png', 'supplier.png', JText::_('COM_JEPROSHOP_SAVE_SUPPLIER_LABEL'), true); JToolbarHelper::custom('developer', 'product_developer.png', 'preview_product_1.png', JText::_('COM_JEPROSHOP_SAVE_DEVELOPER_LABEL'), true); JToolbarHelper::custom('preview', 'preview_product.png', 'preview_product_1.png', JText::_('COM_JEPROSHOP_PREVIEW_LABEL'), true); */ JToolbarHelper::custom('sales', 'sales.png', 'sales.png', JText::_('COM_JEPROSHOP_SALES_LABEL'), true); JToolbarHelper::deleteList('delete'); JToolbarHelper::cancel('cancel'); break; case 'add': JToolbarHelper::title(JText::_('COM_JEPROSHOP_PRODUCT_ADD_PRODUCT_TITLE'), 'jeproshop-product'); JToolbarHelper::apply('save'); JToolbarHelper::save('save_close'); JToolbarHelper::save2new('add2new'); JToolbarHelper::cancel('cancel'); break; default: JToolbarHelper::title(JText::_('COM_JEPROSHOP_PRODUCTS_LIST_TITLE'), 'product-jeproshop'); JToolbarHelper::addNew('add'); JToolbarHelper::editList('edit'); JToolbarHelper::publish('publish'); JToolbarHelper::unpublish('unpublish'); JToolbarHelper::trash('delete'); JToolbarHelper::preferences('com_jeproshop'); JToolbarHelper::help('COM_JEPROSHOP_PRODUCT_MANAGER'); $filter_product_type_options = '<option value="1" >' . JText::_('COM_JEPROSHOP_PRODUCT_SIMPLE_PRODUCT_LABEL') . '</option>'; $filter_product_type_options .= '<option value="2" >' . JText::_('COM_JEPROSHOP_PRODUCT_PACKAGE_LABEL') . '</option>'; $filter_product_type_options .= '<option value="3" >' . JText::_('COM_JEPROSHOP_PRODUCT_VIRTUAL_LABEL') . '</option>'; JHtmlSidebar::addFilter(JText::_('COM_JEPROSHOP_SELECT_PRODUCT_TYPE_LABEL'), 'jform[filter_product_type]', $filter_product_type_options, FALSE); $filter_state_options = '<option value="1" >' . JText::_('COM_JEPROSHOP_FILTER_LABEL') . '</option>'; JHtmlSidebar::addFilter(JText::_('COM_JEPROSHOP_SELECT_STATUS_LABEL'), 'jform[filter_state]', $filter_state_options, FALSE); $categories = JeproshopCategoryModelCategory::getCategories(); $filter_category_options = ''; foreach ($categories as $category) { $filter_category_options .= '<option value="' . $category->category_id . '" >' . ucfirst($category->name) . '</option>'; } JHtmlSidebar::addFilter(JText::_('COM_JEPROSHOP_SELECT_CATEGORY_LABEL'), 'jform[filter_category]', $filter_category_options, FALSE); $manufacturers = JeproshopManufacturerModelManufacturer::getManufacturers(); $filter_manufacturers_options = ''; foreach ($manufacturers as $manufacturer) { $filter_manufacturers_options .= '<option value="' . (int) $manufacturer->manufacturer_id . '" >' . ucfirst($manufacturer->name) . '</option>'; } JHtmlSidebar::addFilter(JText::_('COM_JEPROSHOP_SELECT_MANUFACTURER_LABEL'), 'jform[filter_manufacturer]', $filter_manufacturers_options, FALSE); $suppliers = JeproshopSupplierModelSupplier::getSuppliers(); $filter_suppliers_options = ''; foreach ($suppliers as $supplier) { $filter_suppliers_options .= '<option value="' . (int) $supplier->supplier_id . '" >' . ucfirst($supplier->name) . '</option>'; } JHtmlSidebar::addFilter(JText::_('COM_JEPROSHOP_SELECT_SUPPLIER_LABEL'), 'jform[filter_supplier]', $filter_suppliers_options, FALSE); break; } JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_DASHBOARD_LABEL'), 'index.php?option=com_jeproshop'); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_CATALOG_LABEL'), 'index.php?option=com_jeproshop&task=catalog', true); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_ORDERS_LABEL'), 'index.php?option=com_jeproshop&task=orders'); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_CUSTOMERS_LABEL'), 'index.php?option=com_jeproshop&task=customers'); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_PRICE_RULES_LABEL'), 'index.php?option=com_jeproshop&task=price_rules'); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_SHIPPING_LABEL'), 'index.php?option=com_jeproshop&task=shipping'); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_LOCALIZATION_LABEL'), 'index.php?option=com_jeproshop&task=localization'); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_SETTINGS_LABEL'), 'index.php?option=com_jeproshop&task=settings'); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_ADMINISTRATION_LABEL'), 'index.php?option=com_jeproshop&task=administration'); JHtmlSidebar::addEntry(JText::_('COM_JEPROSHOP_STATS_LABEL'), 'index.php?option=com_jeproshop&task=stats'); }
function getProductList(JeproshopContext $context = NULL) { jimport('joomla.html.pagination'); $db = JFactory::getDBO(); $app = JFactory::getApplication(); $option = $app->input->get('option'); $view = $app->input->get('view'); if (!$context) { $context = JeproshopContext::getContext(); } $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit'), 'int'); $limit_start = $app->getUserStateFromRequest($option . $view . '.limitstart', 'limitstart', 0, 'int'); $lang_id = $app->getUserStateFromRequest($option . $view . '.lang_id', 'lang_id', $context->language->lang_id, 'int'); $shop_id = $app->getUserStateFromRequest($option . $view . '.shop_id', 'shop_id', $context->shop->shop_id, 'int'); $shop_group_id = $app->getUserStateFromRequest($option . $view . '.shop_group_id', 'shop_group_id', $context->shop->shop_group_id, 'int'); $category_id = $app->getUserStateFromRequest($option . $view . '.cat_id', 'cat_id', 0, 'int'); $order_by = $app->getUserStateFromRequest($option . $view . '.order_by', 'order_by', 'date_add', 'string'); $order_way = $app->getUserStateFromRequest($option . $view . '.order_way', 'order_way', 'ASC', 'string'); $published = $app->getUserStateFromRequest($option . $view . '.published', 'published', 0, 'string'); $product_attribute_id = $app->getUserStateFromRequest($option . $view . '.product_attribute_id', 'product_attribute_id', 0, 'int'); if (JeproshopShopModelShop::isFeaturePublished() && $context->cookie->products_filter_category_id) { $category = new JeproshopCategoryModelCategory((int) $context->cookie->products_filter_category_id); if (!$category->inShop()) { $context->cookie->products_filter_category_id = null; $app->redirect('index.php?option=com_jeproshop&view=product'); } } //Join categories table $category_id = (int) $app->input->get('product_filter_category_lang!name'); if ($category_id) { $category = new JeproshopCategoryModelCategory($category_id); $app->input->set('product_filter_category_lang!name', $category->name[$context->language->lang_id]); } else { $category_id = $app->input->get('category_id'); $current_category_id = null; if ($category_id) { $current_category_id = $category_id; $context->cookie->products_filter_category_id = $category_id; } elseif ($category_id = $context->cookie->products_filter_category_id) { $current_category_id = $category_id; } if ($current_category_id) { $category = new JeproshopCategoryModelCategory((int) $current_category_id); } else { $category = new JeproshopCategoryModelCategory(); } } $join_category = false; if (JeproshopTools::isLoadedObject($category, 'category_id') && empty($filter)) { $join_category = true; } $shop_id = JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP ? (int) $this->context->shop->shop_id : "product." . $db->quoteName('default_shop_id'); $join = " LEFT JOIN " . $db->quoteName('#__jeproshop_image') . " AS image ON (image." . $db->quoteName('product_id') . " = product."; $join .= $db->quoteName('product_id') . ") LEFT JOIN " . $db->quoteName('#__jeproshop_stock_available') . " AS stock_available ON (stock_available."; $join .= $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . " AND stock_available." . $db->quoteName('product_attribute_id'); $join .= " = 0 " . JeproshopStockAvailableModelStockAvailable::addShopRestriction(null, 'stock_available') . ") LEFT JOIN " . $db->quoteName('#__jeproshop_product_shop'); $join .= " AS product_shop ON (product." . $db->quoteName('product_id') . " = product_shop." . $db->quoteName('product_id') . " AND product_shop." . $db->quoteName('shop_id'); $join .= " = " . $shop_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_category_lang') . " AS category_lang ON (product_shop." . $db->quoteName('default_category_id'); $join .= " = category_lang." . $db->quoteName('category_id') . " AND product_lang." . $db->quoteName('lang_id') . " = category_lang." . $db->quoteName('lang_id') . " AND category_lang."; $join .= $db->quoteName('shop_id') . " = " . $shop_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_shop') . " AS shop ON (shop." . $db->quoteName('shop_id') . " = " . $shop_id; $join .= ")\tLEFT JOIN " . $db->quoteName('#__jeproshop_image_shop') . " AS image_shop ON (image_shop." . $db->quoteName('image_id') . " = image." . $db->quoteName('image_id'); $join .= " AND image_shop." . $db->quoteName('cover') . " = 1 AND image_shop." . $db->quoteName('shop_id') . " = " . $shop_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_product_download'); $join .= " AS product_download ON (product_download." . $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . ") "; $select = "shop." . $db->quoteName('shop_name') . " AS shop_name, product." . $db->quoteName('default_shop_id') . ", MAX(image_shop." . $db->quoteName('image_id') . ") AS image_id, category_lang."; $select .= $db->quoteName('name') . " AS category_name, product_shop." . $db->quoteName('price') . ", 0 AS final_price, product." . $db->quoteName('is_virtual') . ", product_download."; $select .= $db->quoteName('nb_downloadable') . ", stock_available." . $db->quoteName('quantity') . " AS stock_available_quantity, product_shop." . $db->quoteName('published'); $select .= ", IF(stock_available." . $db->quoteName('quantity') . " <= 0, 1, 0) badge_danger"; if ($join_category) { $join .= " INNER JOIN " . $db->quoteName('#__jeproshop_category_product') . " product_category ON (product_category." . $db->quoteName('product_id') . " = product."; $join .= $db->quoteName('product_id') . " AND product_category." . $db->quoteName('category_id') . " = " . (int) $category->category_id . ") "; $select .= " , product_category." . $db->quoteName('position') . ", "; } $group = " GROUP BY product_shop." . $db->quoteName('product_id'); $use_limit = true; if ($limit === false) { $use_limit = false; } // Add SQL shop restriction $select_shop = $join_shop = $where_shop = $where = $filter = ""; if ($context->controller->shopLinkType) { $select_shop = ", shop.shop_name AS shopname "; $join_shop = ") LEFT JOIN " . $db->quoteName('#__jeproshop_shop') . " AS shop ON product.shop_id = shop.shop_id"; $where_shop = JeproshopShopModelShop::addSqlRestriction($this->shopShareDatas, 'product'); //, $this->shopLinkType } /* Query in order to get results with all fields */ $lang_join = ''; if ($lang_id) { $lang_join = " LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang') . " AS product_lang ON (product_lang."; $lang_join .= $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . " AND product_lang."; $lang_join .= $db->quoteName('lang_id') . " = " . (int) $lang_id; if (!JeproshopShopModelShop::isFeaturePublished()) { $lang_join .= " AND product_lang." . $db->quoteName('shop_id') . " = 1"; } elseif (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) { //$lang_join .= " AND product_lang." . $db->quoteName('shop_id') . " = " . (int)$shop_lang_id; } else { $lang_join .= " AND product_lang." . $db->quoteName('shop_id') . " = product.default_shop_id"; } $lang_join .= ")"; } if ($context->controller->multishop_context && JeproshopShopModelShop::isTableAssociated('product')) { if (JeproshopShopModelShop::getShopContext() != JeproshopShopModelShop::CONTEXT_ALL || !$this->context->employee->isSuperAdmin()) { $test_join = !preg_match('/`?' . preg_quote('#__jeproshop_product_shop') . '`? *product_shop/', $join); if (JeproshopShopModelShop::isFeaturePublished() && $test_join && JeproshopShopModelShop::isTableAssociated('product')) { $where .= " AND product.product_id IN (\tSELECT product_shop.product_id FROM " . $db->quoteName('#__jeproshop_product_shop'); $where .= " AS product_shop WHERE product_shop.shop_id IN ("; $where .= implode(', ', JeproshopShopModelShop::getContextListShopIds()) . "))"; } } } $having_clause = ''; if (isset($filterHaving) || isset($having)) { $having_clause = " HAVING "; if (isset($filterHaving)) { $having_clause .= ltrim($filterHaving, " AND "); } if (isset($having)) { $having_clause .= $having . " "; } } do { $query = "SELECT SQL_CALC_FOUND_ROWS product." . $db->quoteName('product_id') . ", product_lang." . $db->quoteName('name') . ", product."; $query .= $db->quoteName('reference') . ", " . $select . $select_shop . " FROM " . $db->quoteName('#__jeproshop_product') . " AS product "; $query .= $lang_join . $join . $join_shop . " WHERE 1 " . $where . $filter . $where_shop . $group . $having_clause . " ORDER BY "; $query .= (str_replace('`', '', $order_by) == 'product_id' ? "product." : " product.") . $db->quoteName($order_by) . " " . $db->escape($order_way); $db->setQuery($query); $total = count($db->loadObjectList()); $query .= $use_limit === true ? " LIMIT " . (int) $limit_start . ", " . (int) $limit : ""; $db->setQuery($query); $products = $db->loadObjectList(); if ($use_limit == true) { $limit_start = (int) $limit_start - (int) $limit; if ($limit_start < 0) { break; } } else { break; } } while (empty($products)); $this->pagination = new JPagination($total, $limit_start, $limit); return $products; }
/** * Create a link to a category * * @param mixed $category Category object (can be an ID category, but deprecated) * @param string $alias * @param int $lang_id * @param string $selected_filters Url parameter to auto check filters of the module mod_block_layered * @param null $shop_id * @return string */ public function getCategoryLink($category, $alias = null, $lang_id = null, $selected_filters = null, $shop_id = null) { if (!$lang_id) { $lang_id = JeproshopContext::getContext()->language->lang_id; } $url = ""; //$this->getBaseLink($shop_id).$this->getLangLink($lang_id, null, $shop_id); if (!is_object($category)) { $category = new JeproshopCategoryModelCategory($category, $lang_id); } // Set available keywords $params = array(); $params['id'] = $category->category_id; $params['rewrite'] = !$alias ? $category->link_rewrite : $alias; $params['meta_keywords'] = JeproshopTools::str2url($category->getFieldByLang('meta_keywords')); $params['meta_title'] = JeproshopTools::str2url($category->getFieldByLang('meta_title')); // Selected filters is used by the module blocklayered $selected_filters = is_null($selected_filters) ? '' : $selected_filters; if (empty($selected_filters)) { $rule = 'category_rule'; } else { $rule = 'layered_rule'; $params['selected_filters'] = $selected_filters; } return $url; // TODO add query$this->createUrl($rule, $lang_id, $params, $this->allow_link_rewrite, '', $shop_id); }