コード例 #1
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 public function renderDetails($tpl = null)
 {
     $manufacturerModel = new JeproshopManufacturerModelManufacturer();
     $manufacturers = $manufacturerModel->getManufacturerList();
     $this->assignRef('manufacturers', $manufacturers);
     $pagination = $manufacturerModel->getPagination();
     $this->assignRef('pagination', $pagination);
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
コード例 #2
0
ファイル: view.html.php プロジェクト: jeprodev/jeproshop
 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');
 }
コード例 #3
0
ファイル: product.php プロジェクト: jeprodev/jeproshop
 public function __construct($product_id = NULL, $full = FALSE, $lang_id = NULL, $shop_id = NULL, JeproshopContext $context = NULL)
 {
     $db = JFactory::getDBO();
     if ($lang_id !== NULL) {
         $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang');
     }
     if ($shop_id && $this->isMultiShop()) {
         $this->shop_id = (int) $shop_id;
         $this->getShopFromContext = FALSE;
     }
     if ($this->isMultiShop() && !$this->shop_id) {
         $this->shop_id = JeproshopContext::getContext()->shop->shop_id;
     }
     if ($product_id) {
         $cache_id = 'jeproshop_product_model_' . $product_id . '_' . $lang_id . '_' . $shop_id;
         if (!JeproshopCache::isStored($cache_id)) {
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_product') . " AS product ";
             $where = "";
             /** get language information **/
             if ($lang_id) {
                 $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang') . " AS product_lang ";
                 $query .= "ON (product.product_id = product_lang.product_id AND product_lang.lang_id = " . (int) $lang_id . ") ";
                 if ($this->shop_id && !empty($this->multiLangShop)) {
                     $where = " AND product_lang.shop_id = " . $this->shop_id;
                 }
             }
             /** Get shop informations **/
             if (JeproshopShopModelShop::isTableAssociated('product')) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_product_shop') . " AS product_shop ON (";
                 $query .= "product.product_id = product_shop.product_id AND product_shop.shop_id = " . (int) $this->shop_id . ")";
             }
             $query .= " WHERE product.product_id = " . (int) $product_id . $where;
             $db->setQuery($query);
             $product_data = $db->loadObject();
             if ($product_data) {
                 if (!$lang_id && isset($this->multiLang) && $this->multiLang) {
                     $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_product_lang');
                     $query .= " WHERE product_id = " . (int) $product_id;
                     $db->setQuery($query);
                     $product_lang_data = $db->loadObjectList();
                     if ($product_lang_data) {
                         foreach ($product_lang_data as $row) {
                             foreach ($row as $key => $value) {
                                 if (array_key_exists($key, $this) && $key != 'product_id') {
                                     if (!isset($product_data->{$key}) || !is_array($product_data->{$key})) {
                                         $product_data->{$key} = array();
                                     }
                                     $product_data->{$key}[$row->lang_id] = $value;
                                 }
                             }
                         }
                     }
                 }
                 JeproshopCache::store($cache_id, $product_data);
             }
         } else {
             $product_data = JeproshopCache::retrieve($cache_id);
         }
         if ($product_data) {
             $product_data->product_id = $product_id;
             foreach ($product_data as $key => $value) {
                 if (array_key_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     if (!$context) {
         $context = JeproshopContext::getContext();
     }
     if ($full && $this->product_id) {
         $this->isFullyLoaded = $full;
         $this->manufacturer_name = JeproshopManufacturerModelManufacturer::getNameById((int) $this->manufacturer_id);
         $this->supplier_name = JeproshopSupplierModelSupplier::getNameById((int) $this->supplier_id);
         if ($this->getProductType() == self::VIRTUAL_PRODUCT) {
             $this->developer_name = JeproshopDeveloperModelDeveloper::getNameById((int) $this->developer_id);
         }
         $address = NULL;
         if (is_object($context->cart) && $context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')} != null) {
             $address = $context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')};
         }
         $this->tax_rate = $this->getTaxesRate(new JeproshopAddressModelAddress($address));
         $this->is_new = $this->isNew();
         $this->base_price = $this->price;
         $this->price = JeproshopProductModelProduct::getStaticPrice((int) $this->product_id, false, null, 6, null, false, true, 1, false, null, null, null, $this->specific_price);
         $this->unit_price = $this->unit_price_ratio != 0 ? $this->price / $this->unit_price_ratio : 0;
         if ($this->product_id) {
             $this->tags = JeproshopTagModelTag::getProductTags((int) $this->product_id);
         }
         $this->loadStockData();
     }
     if ($this->default_category_id) {
         $this->category = JeproshopCategoryModelCategory::getLinkRewrite((int) $this->default_category_id, (int) $lang_id);
     }
 }
コード例 #4
0
ファイル: controller.php プロジェクト: jeprodev/jeproshop
 /**
  * Create a link to a product
  *
  * @param mixed $product Product object (can be an ID product, but deprecated)
  * @param string $alias
  * @param string $category
  * @param string $ean13
  * @param null $lang_id
  * @param null $shop_id
  * @param int $product_attribute_id ID product attribute
  * @param bool $force_routes
  * @throws JException
  * @internal param int $id_lang
  * @internal param int $id_shop (since 1.5.0) ID shop need to be used when we generate a product link for a product in a cart
  * @return string
  */
 public function getProductLink($product, $alias = null, $category = null, $ean13 = null, $lang_id = null, $shop_id = null, $product_attribute_id = 0, $force_routes = false)
 {
     if (!$lang_id) {
         $lang_id = JeproshopContext::getContext()->language->lang_id;
     }
     if (!is_object($product)) {
         if (is_array($product) && isset($product['product_id'])) {
             $product = new JeproshopProductModelProduct($product['product_id'], false, $lang_id, $shop_id);
         } elseif ((int) $product) {
             $product = new JeproshopProductModelProduct((int) $product, false, $lang_id, $shop_id);
         } else {
             throw new JException(JText::_('COM_JEPROSHOP_INVALID_PRODUCT_VARS_MESSAGE'));
         }
     }
     // Set available keywords
     $anchor = '&task=view&product_id=' . $product->product_id . (!$alias ? '&rewrite=' . $product->getFieldByLang('link_rewrite') : $alias) . (!$ean13 ? '&ean13=' . $product->ean13 : $ean13);
     $anchor .= '&meta_keywords=' . JeproshopTools::str2url($product->getFieldByLang('meta_keywords')) . '&meta_title=' . JeproshopTools::str2url($product->getFieldByLang('meta_title'));
     if ($this->hasKeyword('product', $lang_id, 'manufacturer', $shop_id)) {
         $params['manufacturer'] = JeproshopTools::str2url($product->isFullyLoaded ? $product->manufacturer_name : JeproshopManufacturerModelManufacturer::getNameById($product->manufacturer_id));
     }
     if ($this->hasKeyword('product', $lang_id, 'supplier', $shop_id)) {
         $params['supplier'] = JeproshopTools::str2url($product->isFullyLoaded ? $product->supplier_name : JeproshopSupplierModelSupplier::getNameById($product->supplier_id));
     }
     if ($this->hasKeyword('product', $lang_id, 'price', $shop_id)) {
         $params['price'] = $product->isFullyLoaded ? $product->price : JeproshopProductModelProduct::getStaticPrice($product->product_id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specific_price);
     }
     if ($this->hasKeyword('product', $lang_id, 'tags', $shop_id)) {
         $params['tags'] = JeproshopTools::str2url($product->getTags($lang_id));
     }
     if ($this->hasKeyword('product', $lang_id, 'category', $shop_id)) {
         $params['category'] = !is_null($product->category) && !empty($product->category) ? JeproshopTools::str2url($product->category) : JeproshopTools::str2url($category);
     }
     if ($this->hasKeyword('product', $lang_id, 'reference', $shop_id)) {
         $params['reference'] = JeproshopTools::str2url($product->reference);
     }
     if ($this->hasKeyword('product', $lang_id, 'categories', $shop_id)) {
         $params['category'] = !$category ? $product->category : $category;
         $cats = array();
         foreach ($product->getParentCategories() as $cat) {
             if (!in_array($cat->category_id, Link::$category_disable_rewrite)) {
                 //remove root and home category from the URL
                 $cats[] = $cat->link_rewrite;
             }
         }
         $params['categories'] = implode('/', $cats);
     }
     $anchor .= $product_attribute_id ? '&product_attribute_id=' . $product_attribute_id : '';
     return JRoute::_('index.php?option=com_jeproshop&view=product' . $anchor);
 }