<input type="hidden" class="edit_product_order_detail_id" value="<?php echo (int) $product->order_detail_id; ?> " /> <?php if (isset($product->image) && $product->image->image_id) { echo $product->image_tag; } else { ?> --<?php } ?> </td> <td> <a href="<?php echo JRoute::_('index.php?option=com_jeproshop&view=product&product_id=' . (int) $product->product_id . '&task=update&token=' . JeproshopTools::getProductToken()); ?> "> <span class="productName"><?php echo $product->product_name . ' - ' . JText::_('COM_JEPROSHOP_CUSTOMIZED_LABEL'); ?> </span><br /> <?php if ($product->product_reference) { echo JText::_('COM_JEPROSHOP_REFERENCE_NUMBER_LABEL') . ' : ' . $product->product_reference . '<br />'; } if ($product->product_supplier_reference) { echo JText::_('COM_JEPROSHOP_SUPPLIER_REFERENCE_LABEL') . ' : ' . $product->product_supplier_reference; } ?> </a>
public function delete() { $app = JFactory::getApplication(); $product_id = $app->input->get('product_id'); $product = new JeproshopProductModelProduct((int) $product_id); if (JeproshopTools::isLoadedObject($product, 'product_id') && isset($this->fieldImageSettings)) { // check if request at least one object with noZeroObject if (isset($product->noZeroObject) && count($taxes = call_user_func(array('JeproshopProductModelProduct', $product->noZeroObject))) <= 1) { $this->has_errors = true; JError::raiseError(500, JText::_('COM_JEPROSHOP_YOU_NEED_AT_LEAST_ONE_LABEL') . ' <b> ' . JText::_('COM_JEPROSHOP_PRODUCT_LABEL') . ' </b><br />' . JText::_('COM_JEPROSHOP_YOU_CANNOT_DELETE_ALL_OF_THE_ITEMS_LABEL')); } else { /* * @since 1.5.0 * It is NOT possible to delete a product if there are currently: * - physical stock for this product * - supply order(s) for this product */ if (JeproshopSettingModelSetting::getValue('advanced_stock_management') && $product->advanced_stock_management) { $stock_manager = JeproshopStockManagerFactory::getManager(); $physical_quantity = $stock_manager->getProductPhysicalQuantities($product->product_id, 0); $real_quantity = $stock_manager->getProductRealQuantities($product->product_id, 0); if ($physical_quantity > 0 || $real_quantity > $physical_quantity) { $this->has_errors = true; JError::raiseError('COM_JEPROSHOP_YOU_CANNOT_DELETE_THIS_BECAUSE_THERE_IS_PHYSICAL_STOCK_LEFT_LABEL'); } } if (!$this->has_errors) { if ($product->delete()) { $category_id = (int) $app->input->get('category_id'); $category_url = empty($category_id) ? '' : '&category_id=' . (int) $category_id; $app->enqueueMessage(JText::_('COM_JEPROSHOP_PRODUCT_LABEL') . ' ' . $product->product_id . ' ' . JText::_('COM_JEPROSHOP_WAS_SUCCESSFULLY_DELETED_BY_MESSAGE') . ' ' . JeproshopContext::getContext()->employee->firstname . ' ' . JeproshopContext::getContext()->employee->lastname); $redirect_after = 'index.php?option=com_jeproshop&view=product&conf=1&' . JeproshopTools::getProductToken() . '=1' . $category_url; $app->redirect($redirect_after); } else { $this->has_errors = true; Tools::displayError('An error occurred during deletion.'); } } } } else { $this->has_errors = true; JError::raiseError(500, JText::_('COM_JEPROSHOP_AN_ERROR_OCCURRED_WHILE_DELETING_THE_PRODUCT_MESSAGE') . ' <b> ' . JText::_('COM_JEPROSHOP_PRODUCT_LABEL') . '</b> ' . JText::_('COM_JEPROSHOP_CANNOT_BE_LOADED_MESSAGE')); } }
<td></td> <td></td> </tr> <?php } } if ($product->cart_quantity > $product->customization_quantity) { ?> <tr> <td><?php echo $product->image; ?> </td> <td> <a href="<?php echo JRoute::_('index.php?option=com_jeproshop&view=product&task=update&product_id=' . $product->product_id . '&' . JeproshopTools::getProductToken() . '=1'); ?> " > <span class="product_name"><?php echo $product->name; ?> </span><?php if (isset($product->attributes)) { echo '<br/>' . $product->attributes; } ?> <br/> <?php if ($product->reference) { echo JText::_('COM_JEPROSHOP_REFERENCE_LABEL') . ' ' . $product->reference; }
public function updateProduct() { $db = JFactory::getDBO(); $app = JFactory::getApplication(); $languages = JeproshopLanguageModelLanguage::getLanguages(false); if (!isset($this->context)) { $this->context = JeproshopContext::getContext(); } $this->clearCache(); $this->date_upd = date('Y-m-d H:i:s'); if (JeproshopTools::isLoadedObject($this, 'product_id')) { $this->removeTaxFromEcotax(); $product_type_before = $this->getType(); $this->indexed = 0; $input = JRequest::get('post'); $product_data = isset($input['information']) ? $input['information'] : $input['jform']; $existingProduct = $this; if (JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() != JeproshopShopModelShop::CONTEXT_SHOP) { $this->setFieldsToUpdate((array) $input['multishop_check']); } if ($this->context->shop->getShopContext() == JeproshopShopModelShop::CONTEXT_ALL && !$this->isAssociatedToShop()) { $isAssociatedToShop = false; $combinations = JeproshopProductModelProduct::getProductAttributesIds($this->product_id); if ($combinations) { foreach ($combinations as $combination_id) { $combination = new JeproshopCombinationModelCombination($combination_id); $default_combination = new JeproshopCombinationModelCombination($combination_id, null, $this->default_shop_id); $combination->product_id = (int) $default_combination->product_id; $combination->location = $db->quote($default_combination->location); $combination->ean13 = $db->quote($default_combination->ean13); $combination->upc = $db->quote($default_combination->upc); $combination->quantity = (int) $default_combination->quantity; $combination->reference = $db->quote($default_combination->reference); $combination->supplier_reference = $db->quote($default_combination->supplier_reference); $combination->wholesale_price = (double) $default_combination->wholesale_price; $combination->price = (double) $default_combination->price; $combination->ecotax = (double) $default_combination->ecotax; $combination->weight = $default_combination->weight; $combination->unit_price_impact = (double) $default_combination->unit_price_impact; $combination->default_on = (int) $default_combination->default_on; $combination->available_date = $default_combination->available_date ? $db->quote($default_combination->available_date) : '0000-00-00'; $combination->save(); } } } else { $isAssociatedToShop = true; } $shop_list_ids = JeproshopShopModelShop::getCompleteListOfShopsId(); if (count($this->shop_list_id) > 0) { $shop_list_ids = $this->shop_list_id; } if (JeproshopShopModelShop::checkDefaultShopId('product') && !$this->default_shop_id) { $this->default_shop_id = min($shop_list_ids); } /*$manufacturer_id = $product_data['manufacturer_id']; $default_category_id = 1; $default_shop_id = JeproshopSettingModelSetting::getValue('default_shop'); */ //$tax_rules_group_id = $product_data['tax_rules_group_id']; $show_price = isset($input_data['show_price']) ? 1 : 0; $on_sale = isset($product_data['on_sale']) ? 1 : 0; $online_only = isset($product_data['online_only']) ? 1 : 0; $available_for_order = isset($product_data['available_for_order']) ? 1 : 0; $ean_13 = JeproshopTools::isEan13($product_data['ean13']) ? $product_data['ean13'] : ''; $upc = JeproshopTools::isUpc($product_data['upc']) ? $product_data['upc'] : ''; $reference = JeproshopTools::isReference($product_data['reference']) ? $product_data['reference'] : ''; //$product_type = $product_data['product_type']; $published = $product_data['published']; $redirect_type = $product_data['redirect_type']; /*$ecotax = $product_data['ecotax']; $unity = $product_data['unity']; $unit_price = (float)$product_data['unit_price']; $wholesale_price = (float)$product_data['wholesale_price']; */ $visibility = $product_data['visibility']; $condition = $product_data['condition']; $result = true; /** data base updating **/ $query = "UPDATE " . $db->quoteName('#__jeproshop_product') . " SET " . $db->quoteName('reference') . " = " . $db->quote($reference) . ", " . $db->quoteName('on_sale') . " = " . (int) $on_sale . ", "; $query .= $db->quoteName('online_only') . " = " . (int) $online_only . ", " . $db->quoteName('ean13') . " = " . $db->quote($ean_13) . ", " . $db->quoteName('upc') . " = " . $db->quote($upc) . ", "; $query .= $db->quoteName('published') . " = " . (int) $published . ", " . $db->quoteName('redirect_type') . "= " . $db->quote($redirect_type) . ", " . $db->quoteName('visibility') . " = " . $db->quote($visibility) . ", "; $query .= $db->quoteName('product_redirected_id') . " = " . $db->quote($product_data['product_redirected_id']) . ", " . $db->quoteName('available_for_order') . " = " . (int) $available_for_order . ", "; $query .= $db->quoteName('show_price') . " = " . (int) $show_price . ", " . $db->quoteName('condition') . " = " . $db->quote($condition) . ", " . $db->quoteName('date_upd') . " = " . $db->quote($this->date_upd); $query .= " WHERE " . $db->quoteName('product_id') . " = " . (int) $this->product_id; $db->setQuery($query); $result &= $db->query(); if ($result) { // Database insertion for multishop fields related to the object if (JeproshopShopModelShop::isTableAssociated('product')) { $default_category_id = 1; /* Shop fields */ foreach ($shop_list_ids as $shop_id) { $query = "UPDATE " . $db->quoteName('#__jeproshop_product_shop') . " SET " . $db->quoteName('default_category_id') . " = " . (int) $default_category_id; $query .= ", " . $db->quoteName('online_only') . " = " . (int) $online_only; $query .= ", " . $db->quoteName('redirect_type') . " = " . $db->quote($redirect_type) . ", " . $db->quoteName('product_redirected_id') . " = " . (int) $product_data['product_redirected_id']; $query .= ", " . $db->quoteName('available_for_order') . " = " . (int) $available_for_order . ", " . $db->quoteName('condition') . " = " . $db->quote($product_data['condition']); $query .= ", " . $db->quoteName('published') . " = " . (int) $product_data['published'] . ", " . $db->quoteName('show_price') . " = " . (int) $show_price; //$query .= ", " . $db->quoteName('additional_shipping_cost') . " = " . (float)$product_data['additional_shipping_cost']; $query .= ", " . $db->quoteName('visibility') . " = " . $db->quote($product_data['visibility']) . ", " . $db->quoteName('date_upd') . " = " . $db->quote($this->date_upd); $query .= " WHERE " . $db->quoteName('product_id') . " = " . $this->product_id . " AND " . $db->quoteName('shop_id') . " = " . $shop_id; $db->setQuery($query); $result &= $db->query(); if ($result) { /* Multilingual fields */ foreach ($languages as $language) { $query = "UPDATE " . $db->quoteName('#__jeproshop_product_lang') . " SET " . $db->quoteName('description') . " = "; $query .= $db->quote($product_data['description_' . $language->lang_id]) . ", " . $db->quoteName('short_description'); $query .= " = " . $db->quote($product_data['short_description_' . $language->lang_id]) . ", " . $db->quoteName('name'); $query .= " = " . $db->quote($product_data['name_' . $language->lang_id]) . " WHERE " . $db->quoteName('product_id') . " = "; $query .= (int) $this->product_id . " AND " . $db->quoteName('shop_id'); $query .= " = " . (int) $shop_id . " AND " . $db->quoteName('lang_id') . " = " . (int) $language->lang_id; $db->setQuery($query); $result &= $db->query(); } } } } } if ($result) { // If the product doesn't exist in the current shop but exists in another shop if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP && $existingProduct->isAssociatedToShop($this->context->shop->shop_id)) { $outOfStock = JeproshopStockAvailableModelStockAvailable::outOfStock($existingProduct->product_id, $existingProduct->default_shop_id); $dependsOnStock = JeproshopStockAvailableModelStockAvailable::dependsOnStock($existingProduct->product_id, $existingProduct->default_shop_id); JeproshopStockAvailableModelStockAvailable::setProductOutOfStock((int) $this->product_id, $outOfStock, $this->context->shop->shop_id); JeproshopStockAvailableModelStockAvailable::setProductDependsOnStock((int) $this->product_id, $dependsOnStock, $this->context->shop->shop_id); } if (in_array($this->context->shop->getShopContext(), array(JeproshopShopModelShop::CONTEXT_SHOP, JeproshopShopModelShop::CONTEXT_ALL))) { $this->addCarriers(); $this->updateAccessories(); $this->processSuppliers(); $this->processFeatures(); $this->processProductAttribute(); $this->processProductAttribute(); $this->processPriceAddition(); $this->processSpecificPricePriorities(); $this->processCustomizationConfiguration(); $this->processAttachments(); $this->updatePackItems(); // Disallow advanced stock management if the product become a pack if ($product_type_before == JeproshopProductModelProduct::SIMPLE_PRODUCT && $this->getType() == JeproshopProductModelProduct::PACKAGE_PRODUCT) { JeproshopStockAvailableModelStockAvailable::setProductDependsOnStock($this->product_id, false); } $this->updateDownloadProduct(1); $this->updateTags(JeproshopLanguageModelLanguage::getLanguages(false)); if ($this->isProductFieldUpdated('category_box') && !$this->updateCategories($product_data['category_box'])) { JError::raiseError(500, JText::_('COM_JEPROSHOP_AN_ERROR_OCCURRED_WHILE_LINKING_THE_PRODUCT_TO_CATEGORIES_MESSAGE')); $this->context->controller->has_errors = true; } //TODO correct category update and check php $_POST limit to handle the form } $this->processWarehouses(); $category_link = $app->input->get('category_id') ? '&category_id=' . $app->input->get('category_id') : ''; if (!$this->context->controller->has_errors) { if (in_array($this->visibility, array('both', 'search')) && JeproshopSettingModelSetting::getValue('search_indexation')) { JeproshopSearch::indexation(false, $this->product_id); } //save and preview $message = JText::_('COM_JEPROSHOP_UPDATE_SUCCESSFULLY_MESSAGE'); if ($app->input->get('task') == 'save_preview') { $link = $this->getPreviewUrl(); } else { if ($app->input->get('task') == 'edit') { $link = JRoute::_('index.php?option=com_jeproshop&view=product&task=edit&product_id=' . $this->product_id . $category_link . JeproshopTools::getProductToken()); } else { $link = JRoute::_('index.php?option=com_jeproshop&view=product&' . $category_link); $message = JText::_('COM_JEPROSHOP_UPDATE_SUCCESSFULLY_MESSAGE'); } } $app->redirect($link, $message); } else { $app->input->set('task', 'edit'); $app->redirect('index.php?option=com_jeproshop&view=product&task=edit&product_id=' . $this->product_id . $category_link . JeproshopTools::getProductToken()); } } else { if (!$isAssociatedToShop && $combinations) { foreach ($combinations as $combination_id) { $combination = new JeproshopCombinationModelCombination((int) $combination_id); $combination->delete(); } JError::raiseError(500, JText::_('COM_JEPROSHOP_AN_ERROR_OCCURRED_WHILE_UPDATING_A_PRODUCT_MESSAGE')); } } $this->setGroupReduction(); if ($this->getType() == JeproshopProductModelProduct::VIRTUAL_PRODUCT && $this->published && !JeproshopSettingModelSetting::getValue('virtual_product_feature_active')) { JeproshopSettingModelSetting::updateValue('virtual_product_feature_active', '1'); } return true; } }