Jump to content

How to exclude low stock product from importing


kabir

Recommended Posts

Hi,

I would like to import products from a third-party provided csv file. There are so many products which have very low stock such as, 1 or 2. I would like to import only those products who have a minimum stock of 2. Can you please help me how I can do that with Prestashop store manager or any other way? 

Thanks in advance. 

Link to comment
Share on other sites

Hi,

Thank you very much for your suggestion. But the problem is that I get the CSV file from url link. That's why it is not possible to modify the CSV. Yes, manually I can do that every time after downloading the file form the server but it is huge time consuming.

Link to comment
Share on other sites

How do you download a remote csv file?
How do you import into Prestashop?

 

Editing csv is very simple.
But there are several ways to do it.
For example, you can create a second csv file and insert only lines according to the conditions.

There are many examples of how to do this on the Internet.

Edited by knacky (see edit history)
Link to comment
Share on other sites

$in = fopen('original.csv', 'r');
$out = fopen('new.csv', 'w'); 

while( $row = fgetcsv( $in, 10000)){
  if( $row[5] > 2 ){
    fputcsv($out, $row);
  }
}

fclose($in); 
fclose($out);

unlink('original.csv');

rename('new.csv', 'original.csv');

row[5] is the column number where quantity is. It starts from row[0].

Edited by knacky (see edit history)
Link to comment
Share on other sites

5 hours ago, knacky said:

How do you download a remote csv file?
How do you import into Prestashop?

 

Editing csv is very simple.
But there are several ways to do it.
For example, you can create a second csv file and insert only lines according to the conditions.

There are many examples of how to do this on the Internet.

Hi,

Thank you very much for your help. My suppliers provided me with csv link, for example, https://..............csv.

I use 2 modules which are 'Prestashop Store manager' and 'Product catalog (CSV, Excel) import module' for importing the products into my prestashop.

 

 

 

Link to comment
Share on other sites

5 hours ago, knacky said:
$in = fopen('original.csv', 'r');
$out = fopen('new.csv', 'w'); 

while( $row = fgetcsv( $in, 10000)){
  if( $row[5] > 2 ){
    fputcsv($out, $row);
  }
}

fclose($in); 
fclose($out);

unlink('original.csv');

rename('new.csv', 'original.csv');

row[5] is the column number where quantity is. It starts from row[0].

Thank you very much. I would like to ask you where I should put this expression? 

Link to comment
Share on other sites

Unfortunately, I can't help anymore.
This is just an example of how to remove invalid entries from a CSV file, not a ready-made and functional solution !!!
Ask to modify the module developer.
No one here will research third party modules and give solutions, it's time consuming.

 

Link to comment
Share on other sites

13 minutes ago, knacky said:

Unfortunately, I can't help anymore.
This is just an example of how to remove invalid entries from a CSV file, not a ready-made and functional solution !!!
Ask to modify the module developer.
No one here will research third party modules and give solutions, it's time consuming.

 

Thank you very much for your help. Much appreciated. The mathematical expression you shared will help me lots.

Link to comment
Share on other sites

On 4/2/2022 at 1:32 AM, kabir said:

Hi,

I would like to import products from a third-party provided csv file. There are so many products which have very low stock such as, 1 or 2. I would like to import only those products who have a minimum stock of 2. Can you please help me how I can do that with Prestashop store manager or any other way? 

Thanks in advance. 

you can do it via Store Manager using the expression formula during import, setting a rule for the identification field (e.g. sku) -  if the CSV file with the quantity field is greater than 2 then take the value from the sku column, else empty
with an empty field for identification the product will not be imported, the import result will show how many products were skipped

contact Store Manager support for a formula https://www.prestashopmanager.com/support-center/contact-us/

Link to comment
Share on other sites

7 hours ago, Constantino said:

you can do it via Store Manager using the expression formula during import, setting a rule for the identification field (e.g. sku) -  if the CSV file with the quantity field is greater than 2 then take the value from the sku column, else empty
with an empty field for identification the product will not be imported, the import result will show how many products were skipped

contact Store Manager support for a formula https://www.prestashopmanager.com/support-center/contact-us/

Hi,

 

Thank you very much for your suggestion. Actually Store  manager charge a fee for customized expression if the expression is complex one. If you know any example of this expression and share with us, it would be great.

Thanks again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...