Jump to content

[SOLVED]Update pricing from price supplier


Recommended Posts

Hello all.

Need to update the prices directly from the price supplier on the code manufacturers or supplier code.

Example.
This price supplier:
supplier code | NAME ITEM | code manufacturer | price:
1106734 | CPU Intel CDC E3400 2600/800/1M S775 (oem) SLGTZ | AT80571RG0641ML | 42
1111277 | CPU Intel CDC E3500 2700/800/1M S775 (oem) SLGTY | AT80571RG0681ML | 52
1110725 | CPU Intel PDC E5500 2800/800/2M S775 (oem) SLGTJ | AT80571PG0722ML | 56,5
1111275 | CPU Intel PDC E5700 3000/800/2M S775 (oem) SLGTH | AT80571PG0802ML | 59,5
1111865 | CPU Intel PDC E5700 3000/800/2M S775 (box) SLGTH | BX80571E5700 | 69

Standard module imports do not allow this, because asks for the Product ID and group name. (import->combinations)

Thank you for your answers.

sorry for my english ;)

-----------------------------------------

This:

public static function GETInDatabasID($supplier_reference)
{
 $row = Db::getInstance()->getRow(
 'SELECT supplier_reference,id_product
 FROM '._DB_PREFIX_.'product
 WHERE supplier_reference = "'.$supplier_reference.'"');
       return $row['id_product'];
}  



insert in classes/product.php

This:

$ttttt=Product::GETInDatabasID($info['supplier_reference']);

if ( $ttttt>0)
{
    $info=array('id'=>$ttttt)+$info;;
} 


Insert in (admin)/tabs/adminimport.php after:

public function productImport()
   {
   .......
       {
           if (Tools::getValue('convert'))
               $this->utf8_encode_array($line);
           $info = self::getMaskedRow($line);


You can choose reference, supplier_reference and more.

Tools -> import ->products and update

Link to comment
Share on other sites

  • 2 months later...
  • 4 weeks later...

Does this also allow updating of quantity? I'm not quite following how the code works or what to now use instead of the product id to link it the current database.

I'm going to be importing a weekly update from one of my vendors. The csv file the send me won't have my product id, but it will have the name, which is exactly the same name I'm using in prestashop. Would anyone be able to explain how the above code could be used to achieve my goals or help me on tweaking the code? Thanks in advance.

Link to comment
Share on other sites

instead of supplier_reference put name , or whatever the name of the field you want to match. Ex: I wanted to match the reference number and not the supplier , so I change supplier_reference to reference and it works.

PS: please note that you must check and see what is the real name of the field , because there are many different names , depending on the language that you use. ex: for me the english name is "name_1" and the romanian name is "name_7". And please do a backup first of your DB and the entire shop before you will do this.

Link to comment
Share on other sites

Your example was perfect, since I'm from the US the name_1 is what I need to use. However, I've made the changes and the website goes down. I can go to the site after I've made changes to both of the files and I just get a white page (no errors showing).

However, I can go in and restore the products.php back back to the original coding and the website comes back up. Here is the code that I changed (with a bit above and below the additions). What am I doing wrong? Thanks in advance.

Your example was perfect, since I'm from the US the name_1 is what I need to use. However, I've made the changes and the website goes down. I can go to the site after I've made changes to both of the files and I just get a white page (no errors showing).

However, I can go in and restore the products.php back back to the original coding and the website comes back up. Here is the code that I changed (with a bit above and below the additions). What am I doing wrong? Thanks in advance.


'categories' => array('resource' => 'category', 'fields' => array(
'id' => array('required' => true),
)),
'images' => array('resource' => 'image','fields' => array('id' => array())
),
),
);

public static function GETInDatabasID($name_1)
{
$row = Db::getInstance()->getRow(
'SELECT name_1,id_product
FROM '._DB_PREFIX_.'product
WHERE name_1 = "'.$name_1.'"');
return $row['id_product'];
}

public function getCoverWs()
{
$result = $this->getCover($this->id);
return $result['id_image'];
}

public function getWsImages()
{

Link to comment
Share on other sites

  • 4 weeks later...
×
×
  • Create New...