Jump to content

[SOLVED] Update product price by reference number


Recommended Posts

I found the answer on Español forum, works on 1.4 version but the problem is that deletes the missing fields for example if i don't put the description, suplier, producer... in the csv. file, after update the product description, suplier, producer from the website disappears, please tell me what is wrong. TXS:


in classes/product.php search for:

public static function existsInDatabase($id_product)
   {
       $row = Db::getInstance()->getRow('
       SELECT `id_product`
       FROM '._DB_PREFIX_.'product p
       WHERE p.`id_product` = '.(int)($id_product));

       return isset($row['id_product']);
   }



add this:

public static function refInDatabase($ref)
   {
       $sql = 'SELECT id_product FROM '._DB_PREFIX_.'product WHERE reference = \''.$ref.'\'';
       $tab = Db::getInstance()->getValue($sql);
       return $tab;
   }



should look like this:

public static function existsInDatabase($id_product)
   {
       $row = Db::getInstance()->getRow('
       SELECT `id_product`
       FROM '._DB_PREFIX_.'product p
       WHERE p.`id_product` = '.(int)($id_product));

       return isset($row['id_product']);
   }
   public static function refInDatabase($ref)
   {
       $sql = 'SELECT id_product FROM '._DB_PREFIX_.'product WHERE reference = \''.$ref.'\'';
       $tab = Db::getInstance()->getValue($sql);
       return $tab;
   }



in /admin/tabs/AdminImport.php search for:

if ($product->id AND Product::existsInDatabase((int)($product->id)))
{

                   $datas = Db::getInstance()->getRow('SELECT `date_add` FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)($product->id));
                   $product->date_add = pSQL($datas['date_add']);
                   $res = $product->update();
}



add this before the above code:

if ($product->reference AND Product::refInDatabase($product->reference))
       {                    
                   $product->id = Product::refInDatabase($product->reference); 
       }



should look like this:

if ($product->reference AND Product::refInDatabase($product->reference))
               {                    
                   $product->id = Product::refInDatabase($product->reference); 
               }

               if ($product->id AND Product::existsInDatabase((int)($product->id)))
               {

                   $datas = Db::getInstance()->getRow('SELECT `date_add` FROM `'._DB_PREFIX_.'product` WHERE `id_product` = '.(int)($product->id));
                   $product->date_add = pSQL($datas['date_add']);
                   $res = $product->update();
               }

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

Mike, I copied the classes/products.php from the SVN and dropped it in 1.4.4, and I am not seeing any change in what the import is requiring. It still says " Name* " (required). Neither Reference #, nor Supplier reference # have the asterisk. Is there something I am missing ?

Thanks,

Kathleen

Link to comment
Share on other sites

Hi Kathleen,

The SVN version is not for public use, which means you won't be able to use it in your current storefront. However, we're planning to release it around the end of November, at which point you will be able to use this feature on your live store.

 

If you would like to test it out now, you'll need to do a local install of the SVN version just to test out on your own until it is officially released.

 

-Mike

Link to comment
Share on other sites

  • 4 months later...
  • 4 months later...
  • 2 months later...
×
×
  • Create New...