Beispiel #1
0
 public function edit()
 {
     $this->initModel();
     /// Initialize general elements
     $this->data = array_merge($this->data, $this->parameters);
     $this->data['manufacturers'] = ManufacturerDAO::getInstance()->getManufacturers();
     $this->data['suppliers'] = SupplierDAO::getInstance()->getSuppliers();
     $this->data['textAddEntry'] = $this->language->get("ADD_ENTRY");
     $this->data['textCancel'] = $this->language->get("CANCEL");
     $this->data['textClassName'] = $this->language->get("CLASS");
     $this->data['textDefaultCategories'] = $this->language->get("DEFAULT_CATEGORIES");
     $this->data['textDefaultItemWeight'] = $this->language->get("DEFAULT_ITEM_WEIGHT");
     $this->data['textDefaultManufacturer'] = $this->language->get("DEFAULT_MANUFACTURER");
     $this->data['textDefaultSupplier'] = $this->language->get("DEFAULT_SUPPLIER");
     $this->data['textLocalCategoryId'] = $this->language->get("LOCAL_CATEGORY_ID");
     $this->data['textImportMappedCategoriesOnly'] = $this->language->get("IMPORT_MAPPED_CATEGORIES_ONLY");
     $this->data['textRegularCustomerPriceRate'] = $this->language->get("PRICE_RATE_REGULAR_CUSTOMER");
     $this->data['textRemoveEntry'] = $this->language->get("DELETE");
     $this->data['textSave'] = $this->language->get("SAVE");
     $this->data['textSaveContinueEdit'] = $this->language->get("SAVE_CONTINUE_EDIT");
     $this->data['textSourceSiteCategoryId'] = $this->language->get("SOURCE_SITE_CATEGORY_ID");
     $this->data['textSiteName'] = $this->language->get("SITE");
     $this->data['textStores'] = $this->language->get("STORES");
     $this->data['textWholesaleCustomerPriceRate'] = $this->language->get("PRICE_RATE_WHOLESALE_CUSTOMER");
     $this->data['urlAction'] = $this->selfUrl;
     $this->data['urlList'] = $this->getUrl()->link('extension/import', 'token=' . $this->parameters['token'], 'SSL');
     $this->setBreadcrumbs();
     $this->children = array('common/header', 'common/footer');
     /// Process site data
     $this->data['importSite'] = $this->model;
     if ($this->getRequest()->getMethod() == 'GET') {
         $this->editGET($this->model);
     } elseif ($this->getRequest()->getMethod() == 'POST') {
         $this->editPOST($this->model);
     }
     $this->getResponse()->setOutput($this->render('extension/importForm.tpl.php'));
 }
Beispiel #2
0
 private function getForm()
 {
     if ($this->getConfig()->get('wk_auction_timezone_set')) {
         if (sizeof($this->model->getAuctions())) {
             $this->data['isauction'] = $this->model->getAuctions()[0]->isAuction();
             $this->data['auction_min'] = $this->model->getAuctions()[0]->getMin();
             $this->data['auction_max'] = $this->model->getAuctions()[0]->getMax();
             $this->data['auction_end'] = $this->model->getAuctions()[0]->getEndDate();
             $this->data['auction_start'] = $this->model->getAuctions()[0]->getStartDate();
             $this->data['auction_name'] = $this->model->getAuctions()[0]->getName();
         } else {
             $this->data['isauction'] = 0;
             $this->data['auction_min'] = '';
             $this->data['auction_max'] = '';
             $this->data['auction_end'] = '';
             $this->data['auction_start'] = '';
             $this->data['auction_name'] = '';
         }
     }
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->error['name'])) {
         $this->data['error_name'] = $this->error['name'];
     } else {
         $this->data['error_name'] = array();
     }
     if (isset($this->error['meta_description'])) {
         $this->data['error_meta_description'] = $this->error['meta_description'];
     } else {
         $this->data['error_meta_description'] = array();
     }
     if (isset($this->error['description'])) {
         $this->data['error_description'] = $this->error['description'];
     } else {
         $this->data['error_description'] = array();
     }
     if (isset($this->error['model'])) {
         $this->data['error_model'] = $this->error['model'];
     } else {
         $this->data['error_model'] = '';
     }
     if (isset($this->error['date_available'])) {
         $this->data['error_date_available'] = $this->error['date_available'];
     } else {
         $this->data['error_date_available'] = '';
     }
     $url = '';
     if (isset($this->request->get['sort'])) {
         $url .= '&sort=' . $this->request->get['sort'];
     }
     if (isset($this->request->get['order'])) {
         $url .= '&order=' . $this->request->get['order'];
     }
     if (isset($this->request->get['page'])) {
         $url .= '&page=' . $this->request->get['page'];
     }
     $this->setBreadcrumbs();
     $this->data['model'] = $this->model;
     if (!$this->model->getId()) {
         $this->data['action'] = $this->getUrl()->link('catalog/product/insert', 'token=' . $this->getSession()->data['token'] . $url, 'SSL');
     } else {
         $this->data['action'] = $this->getUrl()->link('catalog/product/update', 'token=' . $this->getSession()->data['token'] . '&product_id=' . $this->model->getId() . $url, 'SSL');
     }
     $this->data['cancel'] = $this->getUrl()->link('catalog/product', 'token=' . $this->getSession()->data['token'] . $url, 'SSL');
     $this->data['token'] = $this->getSession()->data['token'];
     //		if (isset($this->request->get['product_id']) && ($this->request->server['REQUEST_METHOD'] != 'POST')) {
     //			$product_info = ProductDAO::getInstance()->getProduct($this->getRequest()->getParam('product_id'));
     //		}
     $this->data['languages'] = $this->getLoader()->model('localisation/language')->getLanguages();
     //		if (isset($this->request->post['product_description'])) {
     //			$this->data['product_description'] = $this->request->post['product_description'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_description'] = ProductDAO::getInstance()->getDescription($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_description'] = new Description($this->getLanguage()->getId(), '');
     //		}
     //		if (isset($this->request->post['model'])) {
     //			$this->data['model'] = $this->request->post['model'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['model'] = $product_info['model'];
     //		} else {
     //			$this->data['model'] = '';
     //		}
     //		if (isset($this->request->post['sku'])) {
     //			$this->data['sku'] = $this->request->post['sku'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['sku'] = $product_info['sku'];
     //		} else {
     //			$this->data['sku'] = '';
     //		}
     //
     //		if (isset($this->request->post['upc'])) {
     //			$this->data['upc'] = $this->request->post['upc'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['upc'] = $product_info['upc'];
     //		} else {
     //			$this->data['upc'] = '';
     //		}
     //
     //		if (isset($this->request->post['location'])) {
     //			$this->data['location'] = $this->request->post['location'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['location'] = $product_info['location'];
     //		} else {
     //			$this->data['location'] = '';
     //		}
     //		if (isset($this->request->post['image_description'])) {
     //			$this->data['image_description'] = $this->request->post['image_description'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['image_description'] = $product_info['image_description'];
     //		} else {
     //			$this->data['image_description'] = '';
     //		}
     //
     //		if (isset($this->request->post['image'])) {
     //			$this->data['image'] = $this->request->post['image'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['image'] = $product_info['image'];
     //		} else {
     //			$this->data['image'] = '';
     //		}
     //		if (!empty($product_info) && $product_info['image'] && file_exists(DIR_IMAGE . $product_info['image'])) {
     //			$this->data['thumb'] = ImageService::getInstance()->resize($product_info['image'], 100, 100);
     //		} else {
     //			$this->data['thumb'] = ImageService::getInstance()->resize('no_image.jpg', 100, 100);
     //		}
     $this->data['stores'] = StoreDAO::getInstance()->getStores();
     //		if (isset($this->request->post['product_store'])) {
     //			$this->data['product_store'] = $this->request->post['product_store'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_store'] = ProductDAO::getInstance()->getStores($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_store'] = array(0);
     //		}
     //		if (isset($this->request->post['keyword'])) {
     //			$this->data['keyword'] = $this->request->post['keyword'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['keyword'] = $product_info['keyword'];
     //		} else {
     //			$this->data['keyword'] = '';
     //		}
     //		if (isset($this->request->post['product_tag'])) {
     //			$this->data['product_tag'] = $this->request->post['product_tag'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_tag'] = ProductDAO::getInstance()->getProductTags($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_tag'] = array();
     //		}
     $this->data['manufacturers'] = ManufacturerDAO::getInstance()->getManufacturers();
     //		if (isset($this->request->post['manufacturer_id'])) {
     //			$this->data['manufacturer_id'] = $this->request->post['manufacturer_id'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['manufacturer_id'] = $product_info['manufacturer_id'];
     //		} else {
     //			$this->data['manufacturer_id'] = 0;
     //		}
     $this->data['suppliers'] = SupplierDAO::getInstance()->getSuppliers();
     //		if (isset($this->request->post['supplier_id'])) {
     //			$this->data['supplier_id'] = $this->request->post['supplier_id'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['supplier_id'] = $product_info['supplier_id'];
     //		} else {
     //			$this->data['supplier_id'] = 0;
     //		}
     //		if (isset($this->request->post['shipping'])) {
     //			$this->data['shipping'] = $this->request->post['shipping'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['shipping'] = $product_info['shipping'];
     //		} else {
     //			$this->data['shipping'] = 1;
     //		}
     //
     //        if (isset($this->request->post['price'])) {
     //            $this->data['price'] = $this->request->post['price'];
     //        } else if (!empty($product_info)) {
     //            $this->data['price'] = $product_info['price'];
     //        } else {
     //            $this->data['price'] = '';
     //        }
     //		$this->data['tax_classes'] = $this->getLoader()->model('localisation/tax_class')->getTaxClasses();
     //
     //		if (isset($this->request->post['tax_class_id'])) {
     //			$this->data['tax_class_id'] = $this->request->post['tax_class_id'];
     //		} else if (!empty($product_info)) {
     //			$this->data['tax_class_id'] = $product_info['tax_class_id'];
     //		} else {
     //			$this->data['tax_class_id'] = 0;
     //		}
     //		if (isset($this->request->post['date_available'])) {
     //			$this->data['date_available'] = $this->request->post['date_available'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['date_available'] = date('Y-m-d', strtotime($product_info['date_available']));
     //		} else {
     //			$this->data['date_available'] = date('Y-m-d', time() - 86400);
     //		}
     //
     //		if (isset($this->request->post['quantity'])) {
     //			$this->data['quantity'] = $this->request->post['quantity'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['quantity'] = $product_info['quantity'];
     //		} else {
     //			$this->data['quantity'] = '';
     //		}
     //		if (isset($this->request->post['minimum'])) {
     //			$this->data['minimum'] = $this->request->post['minimum'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['minimum'] = $product_info['minimum'];
     //		} else {
     //			$this->data['minimum'] = 1;
     //		}
     //		if (isset($this->request->post['subtract'])) {
     //			$this->data['subtract'] = $this->request->post['subtract'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['subtract'] = $product_info['subtract'];
     //		} else {
     //			$this->data['subtract'] = 0;
     //		}
     //		if (isset($this->request->post['sort_order'])) {
     //			$this->data['sort_order'] = $this->request->post['sort_order'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['sort_order'] = $product_info['sort_order'];
     //		} else {
     //			$this->data['sort_order'] = 1;
     //		}
     $this->data['stock_statuses'] = $this->getLoader()->model('localisation/stock_status')->getStockStatuses();
     //
     //		if (isset($this->request->post['stock_status_id'])) {
     //			$this->data['stock_status_id'] = $this->request->post['stock_status_id'];
     //		} else if (!empty($product_info)) {
     //			$this->data['stock_status_id'] = $product_info['stock_status_id'];
     //		} else {
     //			$this->data['stock_status_id'] = $this->getConfig()->get('config_stock_status_id');
     //		}
     //		if (isset($this->request->post['status'])) {
     //			$this->data['status'] = $this->request->post['status'];
     //		} else if (!empty($product_info)) {
     //			$this->data['status'] = $product_info['status'];
     //		} else {
     //			$this->data['status'] = 1;
     //		}
     //		if (isset($this->request->post['affiliate_commission'])) {
     //			$this->data['affiliate_commission'] = $this->request->post['affiliate_commission'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['affiliate_commission'] = $product_info['affiliate_commission'];
     //		} else {
     //			$this->data['affiliate_commission'] = 0;
     //		}
     //		if (isset($this->request->post['weight'])) {
     //			$this->data['weight'] = $this->request->post['weight'];
     //		} else if (!empty($product_info)) {
     //			$this->data['weight'] = $product_info['weight'];
     //		} else {
     //			$this->data['weight'] = '';
     //		}
     $this->data['weight_classes'] = MeasureUnitDAO::getInstance()->getWeightClasses();
     //
     //		if (isset($this->request->post['weight_class_id'])) {
     //			$this->data['weight_class_id'] = $this->request->post['weight_class_id'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['weight_class_id'] = $product_info['weight_class_id'];
     //		} else {
     //			$this->data['weight_class_id'] = $this->getConfig()->get('config_weight_class_id');
     //		}
     //		if (isset($this->request->post['length'])) {
     //			$this->data['length'] = $this->request->post['length'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['length'] = $product_info['length'];
     //		} else {
     //			$this->data['length'] = '';
     //		}
     //
     //		if (isset($this->request->post['width'])) {
     //			$this->data['width'] = $this->request->post['width'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['width'] = $product_info['width'];
     //		} else {
     //			$this->data['width'] = '';
     //		}
     //
     //		if (isset($this->request->post['height'])) {
     //			$this->data['height'] = $this->request->post['height'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['height'] = $product_info['height'];
     //		} else {
     //			$this->data['height'] = '';
     //		}
     //		$this->getLoader()->model('localisation/length_class');
     $this->data['length_classes'] = MeasureUnitDAO::getInstance()->getLengthClasses();
     //		if (isset($this->request->post['length_class_id'])) {
     //			$this->data['length_class_id'] = $this->request->post['length_class_id'];
     //		} elseif (!empty($product_info)) {
     //			$this->data['length_class_id'] = $product_info['length_class_id'];
     //		} else {
     //			$this->data['length_class_id'] = $this->getConfig()->get('config_length_class_id');
     //		}
     //		if (isset($this->request->post['product_attribute'])) {
     //			$this->data['product_attributes'] = $this->request->post['product_attribute'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_attributes'] = ProductDAO::getInstance()->getProductAttributes($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_attributes'] = array();
     //		}
     //		$this->data['product_options'] = array();
     //		if (isset($this->request->post['product_option'])) {
     //			$product_options = $this->request->post['product_option'];
     //            $product_options = new ProductOptionCollection();
     //            foreach ($this->getRequest()->getParam('product_option') as $productOptionParam) {
     //                $productOption = new ProductOption(
     //                    $productOptionParam['product_option_id'],
     //                    Produ
     //                )
     //            }
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$product_options = ProductDAO::getInstance()->getProductOptions($this->request->get['product_id']);
     //		} else {
     //			$product_options = [];
     //		}
     //
     //
     //		foreach ($product_options as $product_option) {
     //			if ($product_option->getType() == 'select' || $product_option->getType() == 'radio' || $product_option->getType() == 'checkbox' || $product_option->getType() == 'image') {
     //				$product_option_value_data = array();
     //
     //				foreach ($product_option->getValue() as $product_option_value) {
     //					$product_option_value_data[] = array(
     //						'product_option_value_id' => $product_option_value->getId(),
     //						'option_value_id'         => $product_option_value->getOptionValue()->getId(),
     //						'quantity'                => $product_option_value->getQuantity(),
     //						'subtract'                => $product_option_value->getSubtract(),
     //						'price'                   => $product_option_value->getPrice(),
     //						'price_prefix'            => $product_option_value->getPrice() > 0 ? '+' : '-',
     //						'points'                  => $product_option_value->getPoints(),
     //						'points_prefix'           => $product_option_value->getPoints() > 0 ? '+' : '-',
     //						'weight'                  => $product_option_value->getWeight(),
     //						'weight_prefix'           => $product_option_value->getWeight() > 0 ? '+' : '-'
     //					);
     //				}
     //
     //				$this->data['product_options'][] = array(
     //					'product_option_id'    => $product_option->getId(),
     //					'option_id'            => $product_option->getOption()->getId(),
     //					'name'                 => $product_option->getOption()->getName(),
     //					'type'                 => $product_option->getType(),
     //					'product_option_value' => $product_option_value_data,
     //					'required'             => $product_option->isRequired()
     //				);
     //			} else {
     //				$this->data['product_options'][] = array(
     //					'product_option_id' => $product_option->getId(),
     //					'option_id'         => $product_option->getOption()->getId(),
     //					'name'              => $product_option->getOption()->getName(),
     //					'type'              => $product_option->getType(),
     //					'option_value'      => $product_option->getValue(),
     //					'required'          => $product_option->isRequired()
     //				);
     //			}
     //		}
     $this->data['create_option_block'] = $this->getOptionForm();
     $this->data['customer_groups'] = $this->getLoader()->model('sale/customer_group')->getCustomerGroups();
     //		if (isset($this->request->post['product_discount'])) {
     //			$this->data['product_discounts'] = $this->request->post['product_discount'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_discounts'] = ProductDAO::getInstance()->getProductDiscounts($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_discounts'] = array();
     //		}
     //		if (isset($this->request->post['product_special'])) {
     //			$this->data['product_specials'] = $this->request->post['product_special'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_specials'] = ProductDAO::getInstance()->getProductSpecials($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_specials'] = array();
     //		}
     //		if (isset($this->request->post['product_image'])) {
     //			$product_images = $this->request->post['product_image'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$product_images = ProductDAO::getInstance()->getProductImages($this->request->get['product_id']);
     //		} else {
     //			$product_images = array();
     //		}
     $this->data['product_images'] = array();
     foreach ($this->model->getImages() as $productImage) {
         if (file_exists(DIR_IMAGE . $productImage->getImagePath())) {
             $image = $productImage->getImagePath();
         } else {
             $image = 'no_image.jpg';
         }
         $this->data['product_images'][] = array('image' => $image, 'thumb' => ImageService::getInstance()->resize($image, 100, 100), 'sort_order' => $productImage->getSortOrder());
     }
     $this->data['no_image'] = ImageService::getInstance()->resize('no_image.jpg', 100, 100);
     $this->data['downloads'] = $this->getLoader()->model('catalog/download')->getDownloads();
     //		if (isset($this->request->post['product_download'])) {
     //			$this->data['product_download'] = $this->request->post['product_download'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_download'] = ProductDAO::getInstance()->getProductDownloads($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_download'] = array();
     //		}
     $categories = CategoryDAO::getInstance()->getAllCategories();
     $this->data['categories'] = $this->getAllCategories($categories);
     //		if (isset($this->request->post['main_category_id'])) {
     //			$this->data['main_category_id'] = $this->request->post['main_category_id'];
     //		} elseif (isset($product_info)) {
     //			$this->data['main_category_id'] = $this->model_catalog_product->getProductMainCategoryId($this->request->get['product_id']);
     //		} else {
     //			$this->data['main_category_id'] = 0;
     //		}
     //		if (isset($this->request->post['product_category'])) {
     //			$this->data['product_category'] = $this->request->post['product_category'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_category'] = $this->model_catalog_product->getProductCategories($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_category'] = array();
     //		}
     $this->data['categoriesParent'] = $this->getCategoriesParent(0, array_map(function (ProductCategory $item) {
         return $item->getCategory()->getId();
     }, $this->model->getCategories()));
     //		$this->data['scripts'] = '$("#navigation ul").treeview({persist: "location",	collapsed: true, unique: true	});';
     //		if (isset($this->request->post['product_related'])) {
     //			$products = $this->request->post['product_related'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$products = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
     //		} else {
     //			$products = array();
     //		}
     //
     //		$this->data['product_related'] = array();
     //
     //		foreach ($products as $product_id) {
     //			$related_info = $this->model_catalog_product->getProduct($product_id);
     //
     //			if ($related_info) {
     //				$this->data['product_related'][] = array(
     //					'product_id' => $related_info['product_id'],
     //					'name'       => $related_info['name']
     //				);
     //			}
     //		}
     //		if (isset($this->request->post['points'])) {
     //			$this->data['points'] = $this->request->post['points'];
     //		} else if (!empty($product_info)) {
     //			$this->data['points'] = $product_info['points'];
     //		} else {
     //			$this->data['points'] = '';
     //		}
     //		if (isset($this->request->post['koreanName'])) {
     //			$this->data['koreanName'] = $this->request->post['koreanName'];
     //		} else if (!empty($product_info)) {
     //			$this->data['koreanName'] = $product_info['korean_name'];
     //		} else {
     //			$this->data['koreanName'] = '';
     //		}
     //		if (isset($this->request->post['supplierUrl'])) {
     //			$this->data['supplierUrl'] = $this->request->post['supplierUrl'];
     //		} else if (!empty($product_info)) {
     //			$this->data['supplierUrl'] = $product_info['supplier_url'];
     //		} else {
     //			$this->data['supplierUrl'] = '';
     //		}
     //		if (isset($this->request->post['product_reward'])) {
     //			$this->data['product_reward'] = $this->request->post['product_reward'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_reward'] = $this->model_catalog_product->getProductRewards($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_reward'] = array();
     //		}
     //		if (isset($this->request->post['product_layout'])) {
     //			$this->data['product_layout'] = $this->request->post['product_layout'];
     //		} elseif (isset($this->request->get['product_id'])) {
     //			$this->data['product_layout'] = $this->model_catalog_product->getProductLayouts($this->request->get['product_id']);
     //		} else {
     //			$this->data['product_layout'] = array();
     //		}
     $this->data['layouts'] = $this->getLoader()->model('design/layout')->getLayouts();
     $this->children = array('common/header', 'common/footer');
     $this->getResponse()->setOutput($this->render('catalog/productForm.tpl.php'));
 }
 /**
  * @return Manufacturer
  */
 public function getRelatedManufacturer()
 {
     if (!isset($this->relatedManufacturer)) {
         $this->relatedManufacturer = new Mutable(SupplierDAO::getInstance()->getRelatedManufacturer($this->id));
     }
     return $this->relatedManufacturer->get();
 }
 /**
  * @return Supplier
  */
 public function getSupplier()
 {
     if (!isset($this->supplier)) {
         $this->supplier = SupplierDAO::getInstance()->getSupplier($this->supplierId, true);
     }
     return $this->supplier;
 }
 private function validateDelete()
 {
     if (!$this->user->hasPermission('modify', 'catalog/supplier_group')) {
         $this->error['warning'] = $this->language->get('error_permission');
     }
     foreach ($this->request->post['selected'] as $supplier_group_id) {
         $supplier_total = SupplierDAO::getInstance()->getTotalSuppliersBySupplierGroupId($supplier_group_id);
         if ($supplier_total) {
             $this->error['warning'] = sprintf($this->language->get('error_supplier'), $supplier_total);
         }
     }
     if (!$this->error) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * @param array $data
  * @return Supplier[]
  */
 public function getOrderItemsSuppliers($data = array())
 {
     unset($data['filterSupplierId']);
     $filter = $this->buildFilter($data);
     $query = "\n            SELECT DISTINCT s.supplier_id\n            FROM " . $this->orderItemsFromQuery . ($filter->isFilterSet() ? "WHERE " . $filter->getFilterString() : "");
     $result = array();
     foreach ($this->getDb()->query($query, $filter->getParams())->rows as $supplierId) {
         $result[] = SupplierDAO::getInstance()->getSupplier($supplierId['supplier_id']);
     }
     return $result;
 }
Beispiel #7
0
 public function index()
 {
     $this->load->language('module/mpchanges');
     $this->load->model('catalog/category');
     $this->load->model('setting/store');
     $this->load->model('sale/customer_group');
     $this->setBreadcrumbs([['text' => $this->language->get('text_module'), 'route' => 'extension/module']]);
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     $this->document->setTitle($this->language->get('heading_title'));
     $this->data['token'] = $this->session->data['token'];
     $this->data['url_cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['action_change_price'] = $this->url->link('module/mpchanges/changeprice', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['action_change_specials'] = $this->url->link('module/mpchanges/changespecial', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['action_save_specials'] = $this->url->link('module/mpchanges/addspecial', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['action_change_discounts'] = $this->url->link('module/mpchanges/changediscounts', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['action_save_discounts'] = $this->url->link('module/mpchanges/adddiscounts', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['action_del_elements'] = $this->url->link('module/mpchanges/delelements', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['urlGetOptionValues'] = $this->url->link('module/mpchanges/getOptionValues', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['urlGetProgress'] = $this->url->link('module/mpchanges/getProgress', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['urlSetOption'] = $this->url->link('module/mpchanges/setOption', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['customer_groups'] = $this->model_sale_customer_group->getCustomerGroups();
     $this->data['manufacturers'] = ManufacturerDAO::getInstance()->getManufacturers();
     $this->data['suppliers'] = SupplierDAO::getInstance()->getSuppliers();
     $this->data['categories'] = $this->model_catalog_category->getCategories();
     $this->data['options'] = OptionDAO::getInstance()->getOptions();
     $this->children = array('common/header', 'common/footer');
     $this->getResponse()->setOutput($this->render('module/mpchanges.tpl.php'));
 }
 /**
  * @return ImportSourceSite[]
  */
 public function getSourceSites()
 {
     $query = $this->getDb()->query("SELECT * FROM imported_source_sites");
     $result = array();
     foreach ($query->rows as $siteEntry) {
         $result[] = new ImportSourceSite($siteEntry['class_name'], null, preg_split('/,/', $siteEntry['default_category_id']), ManufacturerDAO::getInstance()->getManufacturer($siteEntry['default_manufacturer_id'], true), SupplierDAO::getInstance()->getSupplier($siteEntry['default_supplier_id'], true), $siteEntry['import_mapped_categories_only'], $siteEntry['name'], $siteEntry['regular_customer_price_rate'], preg_split('/,/', $siteEntry['default_store_id']), $siteEntry['wholesale_customer_price_rate'], $siteEntry['default_weight']);
     }
     return $result;
 }
 /**
  * @param int $productId
  * @return Supplier
  */
 public function getSupplier($productId)
 {
     $supplierId = $this->getSingleValue($productId, 'supplier_id');
     return SupplierDAO::getInstance()->getSupplier($supplierId);
 }
Beispiel #10
0
 private function validateInsert()
 {
     $supplier_info = SupplierDAO::getInstance()->getSupplierByName($this->parameters['name']);
     if ($supplier_info) {
         $this->error['warning'] = $this->language->get('error_exists');
     }
     return !$this->error;
 }