示例#1
0
 public function getFieldsValues()
 {
     $items = ManufacturerCore::getManufacturers();
     foreach ($items as $item) {
         if (Tools::getValue('manufacturer_' . (int) $item['id_manufacturer'])) {
             $this->manufacturer[] = $item['id_manufacturer'];
         }
     }
 }
 public function getAllManufacturers()
 {
     $manufacturers = ManufacturerCore::getManufacturers();
     $items = array();
     foreach ($manufacturers as $manufacturer) {
         $items[] = array('id' => $manufacturer['id_manufacturer'], 'name' => $manufacturer['name']);
     }
     $this->manufacturers = $items;
 }
 /**
  * Display the module content on the left column. Prepares the data and then calls
  * views/templates/hook/blockmanufacturers.tpl
  *
  * @param $params
  * @return mixed
  */
 public function hookDisplayLeftColumn($params)
 {
     $current_manufacturer_id = 0;
     if (Tools::getValue('id_product')) {
         $product = new ProductCore(Tools::getValue('id_product'));
         $current_manufacturer_id = $product->id_manufacturer;
     }
     if (Tools::getValue('id_manufacturer')) {
         $current_manufacturer_id = Tools::getValue('id_manufacturer');
     }
     $manufacturers = ManufacturerCore::getManufacturers();
     // assigning to each manufacturer his own shop url link
     if (isset($manufacturers)) {
         $link = new Link();
         foreach ($manufacturers as $key => $manufacturer) {
             $manufacturer = new ManufacturerCore($manufacturer['id_manufacturer']);
             $manufacturers[$key]['link'] = $link->getManufacturerLink($manufacturer);
         }
     }
     $this->context->smarty->assign(array('manufacturers' => $manufacturers, 'current_manufacturer_id' => $current_manufacturer_id));
     return $this->display(__FILE__, 'blockmanufacturers.tpl');
 }
示例#4
0
    public static function getProducts($id_manufacturer, $id_lang, $p, $n, $orderBy = NULL, $orderWay = NULL, $getTotal = false, $active = true, $active_category = true, Context $context = NULL)
    {
        global $cookie;
        $agile_sql_parts = AgileSellerManager::getAdditionalSqlForProducts("p");
        if (empty($agile_sql_parts['joins']) or empty($agile_sql_parts['wheres'])) {
            parent::getProducts($id_manufacturer, $id_lang, $p, $n, $orderBy, $orderWay, $getTotal, $active, $active_category);
        }
        if ($p < 1) {
            $p = 1;
        }
        if (empty($orderBy) || $orderBy == 'position') {
            $orderBy = 'name';
        }
        if (empty($orderWay)) {
            $orderWay = 'ASC';
        }
        if (!Validate::isOrderBy($orderBy) or !Validate::isOrderWay($orderWay)) {
            die(Tools::displayError());
        }
        $groups = FrontController::getCurrentCustomerGroups();
        $sqlGroups = count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1';
        if ($getTotal) {
            $sql = '
				SELECT p.`id_product`
				FROM `' . _DB_PREFIX_ . 'product` p
			    ' . $agile_sql_parts['joins'] . '
				WHERE p.id_manufacturer = ' . (int) $id_manufacturer . ($active ? ' AND p.`active` = 1' : '') . '
    			' . $agile_sql_parts['wheres'] . '
				AND p.`id_product` IN (
					SELECT cp.`id_product`
					FROM `' . _DB_PREFIX_ . 'category_group` cg
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)' . ($active_category ? ' INNER JOIN `' . _DB_PREFIX_ . 'category` ca ON cp.`id_category` = ca.`id_category` AND ca.`active` = 1' : '') . '
					WHERE cg.`id_group` ' . $sqlGroups . '
				)';
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
            return (int) sizeof($result);
        }
        $sql = '
		SELECT p.*, pa.`id_product_attribute`, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, tl.`name` AS tax_name, t.`rate`, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY)) > 0 AS new,
			(p.`price` * ((100 + (t.`rate`))/100)) AS orderprice
			' . $agile_sql_parts['selects'] . '
		FROM `' . _DB_PREFIX_ . 'product` p
			    ' . $agile_sql_parts['joins'] . '
		LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON (p.`id_product` = pa.`id_product` AND default_on = 1)
		LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) $id_lang . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
		LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
		                                           AND tr.`id_country` = ' . (int) (_PS_VERSION_ > '1.5' ? Context::getContext()->country->id : Country::getDefaultCountryId()) . '
	                                           	   AND tr.`id_state` = 0)
	    LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON (t.`id_tax` = tr.`id_tax`)
		LEFT JOIN `' . _DB_PREFIX_ . 'tax_lang` tl ON (t.`id_tax` = tl.`id_tax` AND tl.`id_lang` = ' . (int) $id_lang . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON m.`id_manufacturer` = p.`id_manufacturer`
		WHERE p.`id_manufacturer` = ' . (int) $id_manufacturer . ($active ? ' AND p.`active` = 1' : '') . '
			' . $agile_sql_parts['wheres'] . '
		AND p.`id_product` IN (
					SELECT cp.`id_product`
					FROM `' . _DB_PREFIX_ . 'category_group` cg
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)' . ($active_category ? ' INNER JOIN `' . _DB_PREFIX_ . 'category` ca ON cp.`id_category` = ca.`id_category` AND ca.`active` = 1' : '') . '
					WHERE cg.`id_group` ' . $sqlGroups . '
				)
		ORDER BY ' . ($orderBy == 'id_product' ? 'p.' : '') . '`' . pSQL($orderBy) . '` ' . pSQL($orderWay) . '
		LIMIT ' . ((int) $p - 1) * (int) $n . ',' . (int) $n;
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
        if (!$result) {
            return false;
        }
        if ($orderBy == 'price') {
            Tools::orderbyPrice($result, $orderWay);
        }
        $finalResults = Product::getProductsProperties($id_lang, $result);
        $finalResults = AgileSellerManager::prepareSellerRattingInfo($finalResults);
        return $finalResults;
    }
示例#5
0
        else{
            $resources->id_category_default = intval($category_id);
        }
        $resources->associations->categories->addChild('categories')->addChild('id',intval($category_id));
            
        
        $resources->item_number = $product_xml->ItemNumber;
        $parameter = array("ItemNumber"=>$product_xml->ItemNumber,
			"key"=>"8770471727");
        $product_details = $webservice_exi->GetDetails($parameter);
        $product_details = $product_details->GetDetailsResult->productinfopromo;
        $resources->active = 1;
        $resources->available_for_order = 1;
        $resources->show_price = 1;
        if($product_xml->Brand!=''){
            $brand_id = ManufacturerCore::getIdByName($product_xml->Brand);
            if(!$brand_id)
               $brand_id = add_new_manufacturer($product_xml->Brand);
            $resources->id_manufacturer = $brand_id;
        }
        
        $parameter = array("SKU"=>$product_xml->SKU,
                        "list" => $list,
			"key"=>"8770471727");
        $quick_quote = $webservice_exi->GetQuote($parameter);
        
        //var_dump($quick_quote);
        if(isset($quick_quote->GetQuoteResult->QuickQuote)){
        
        $quick_quote = $quick_quote->GetQuoteResult->QuickQuote;
        $resources->quick_quote = json_encode($quick_quote);
 /**
  * Get all Manufacturer
  *
  * @param bool $get_nb_products
  * @param int $id_lang
  * @param bool $active
  * @param bool $p
  * @param bool $n
  * @param bool $all_group
  * @param bool $group_by
  *
  * @return array Manufacturer
  */
 public function getManufacturers($get_nb_products = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_group = false, $group_by = false)
 {
     return \ManufacturerCore::getManufacturers($get_nb_products, $id_lang, $active, $p, $n, $all_group, $group_by);
 }
示例#7
0
    protected function getShowManufactory($manufactories = array())
    {
        $result = '';
        if ($manufactories) {
            foreach ($manufactories as $manufactory) {
                $manufactoryName = ManufacturerCore::getNameById($manufactory);
                $result .= '<li id="manufacturer-' . $manufactory . '">
								<input type="hidden" class="manufactories" name="manufacturers[]" value="' . $manufactory . '" />
								<span>' . $manufactoryName . '</span>
								<a class="link-trash-manufacturer pull-right" data-id="' . $manufactory . '"><i class="icon-trash "></i></a>
							</li>';
            }
        }
        return $result;
    }
 /**
  * Creates a Manufacturer in Prestashop if not exists, return manufacturer id elsewhere.
  * 
  * @param string $name_manufacturer
  * @return integer 
  *
  */
 private function setManufacturerForProduct($name_manufacturer)
 {
     $id_manufacturer = 0;
     $manufacturer = new ManufacturerCore();
     $id_manufacturer = $manufacturer::getIdByName(trim($name_manufacturer));
     if (!$id_manufacturer) {
         $manufacturer->name = trim($name_manufacturer);
         $manufacturer->add();
         $id_manufacturer = $manufacturer->id;
     }
     return $id_manufacturer;
 }
示例#9
0
    public function hookOrderConfirmation($params)
    {
        $context = Context::getContext();
        $id_card = $context->cart->id;
        $id_order = Order::getOrderByCartId(intval($id_cart));
        $order = $params['objOrder'];
        $products = $order->getProducts();
        $dl = '<script>
   		$(window).load(function() {
	window.dataLayer.push({
	    "ecommerce": {
	        "purchase": {
	            "actionField": {
	                "id" : "' . $order->id . '",
	            },
	            "products": [';
        foreach ($products as $product) {
            //id_manufacturer
            //id_category_default
            //product_attribute_id
            $price = $product['total_price'];
            $revenue = $price / 100 * 20;
            $brand = ManufacturerCore::getNameById($product['id_manufacturer']);
            $name = ProductCore::getProductName($product['product_id']);
            $category = CategoryCore::getUrlRewriteInformations($product['id_category_default']);
            $variant = $this->getAttributeName($product['product_attribute_id']);
            $dl .= '{
	                    "id": "' . $product['product_id'] . '",
	                    "name": "' . $name . '",
	                    "price": ' . $price . ',
	                    "brand": "' . $brand . '",
	                    "category": "' . $category[0]['link_rewrite'] . '",
	                    "variant": "' . $variant . '",
	                    "quantity": ' . $product['product_quantity'] . ',
	                    "revenue": ' . $revenue . ',
	                    "shipping": ' . $order->total_shipping . '
	                },';
        }
        $dl .= ']
	        }
	    }
	});
	';
        foreach ($products as $product) {
            $price = $product['total_price'];
            $revenue = $price / 100 * 20;
            $name = ProductCore::getProductName($product['product_id']);
            $category = CategoryCore::getUrlRewriteInformations($product['id_category_default']);
            $brand = ManufacturerCore::getNameById($product['id_manufacturer']);
            $variant = $this->getAttributeName($product['product_attribute_id']);
            $dl .= '/* ga("ec:addProduct", {
				  "id": "' . $product['product_id'] . '",
				  "name": "' . $name . '",
				  "category": "' . $category[0]['link_rewrite'] . '",
				  "brand": "' . $brand . '",
				  "variant": "' . $variant . '",
				  "price": "' . $price . '",
				  "quantity": ' . $product['product_quantity'] . '
				});
				';
        }
        $dl .= 'ga("ec:setAction", "purchase", {
		  "id" : "' . $order->id . '",
		  "affiliation": location.hosts,
		  "revenue": "' . $order->total_paid_real . '",
		  "shipping": "' . $order->total_shipping . '"
		});

		ga("send", "pageview");
   		})*/; 
   		</script>';
        return $dl;
    }