Jump to content

[Help] Blank product on new products module and page


german

Recommended Posts

For some reason I'm getting a weird bug, I get a blank product in the "New Products" module and page, and that product is nowhere, none of my products is empty like that. 

I'm using Prestashop 1.7 and I talked to the theme creator (theme: MegaShop, Creator: templating) and he says it is not related to his theme (so he won't support me on this). 

Could you please any of you help me with it? You can find the issue here:


https://new.germanmedina.es/novedades

Link to comment
Share on other sites

  • 2 weeks later...

Hi There.. The problem is indeed related to PS 1.7.x.
It has been there the whole 1.7.x cycle, and still is in current 1.7.4.2 stable version.
I can easily duplicate this issue in a blank PS installation, with the default "classic" theme.

 

For others with same issue, this is the cause:

  1. Start adding new product in catalogue.
  2. Don't save the product. Leave the product configuration window by clicking previous button in browser. Or click any menu item, just don't save the procuct!
  3. Now there is a new product inside the database. There is a new product id (assigned to category id 2 (home)), but the product remains empty.
    Note: You will not see this product in BO product listing. You can only see it inside database. But if you would create another product and save it as should, you would see that the product ID has skipped a number (because PS created an empty product before).

 

Possible solution:

When you have this issue. You would have to login to your database to manually remove the product from the products table..
You may want to compare product ID's with your backoffice to identify the empty products. The product ID's that are not visible in BO are the empty products.


 

I've been doing this manually in several webshop for a few months now. :(
Hopefully this issue will be fixed soon in future PS releases.
 

Cheers!

Edited by Tomasci
fixed some typo (see edit history)
Link to comment
Share on other sites

7 minutes ago, Tomasci said:

Hi There.. The problem is indeed related to PS 1.7.x.
It has been there the whole 1.7.x cycle, and still is in current 1.7.4.2 stable version.
I can easily duplicate this issue in a blank PS installation, with the default "classic" theme.

 

For others with same issue, this is the cause:

  1. Start adding new product in catalogue.
  2. Don't save the product. Leave the product configuration window by clicking previous button in browsers. Or click any menu item, just don't save the procuct!
  3. Now there is a new product inside the database. There is a new product id (assinged to category id 3 (home)), but the product remains empty.
    Note: You will not see this product in BO product listing. You can only see it inside database. But if you would create another product and save it as should, you would see that the product ID has skipped a number (because PS created an empty product before).

 

Possible solution:

When you have this issue. You would have to login to your database to manually remove the product from the products table..
You may want to compare product ID's with your backoffice to identify the empty products. The product ID's that are not visible in BO are the empty products.


 

I've been doing this manually in several webshop for a few months now. :(
Hopefully this issue will be fixed soon in future PS releases.
 

Cheers!

I don't understand how they don't realease a "urgent" release to fix these kind of things. 

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

 

Yes. It can be very annoying when lots of products are added. I now use a simple SQL Query in backoffice (advanced settings) to determine if there are blank products like this. You could create a query like the below to check for blank products:

SELECT *
FROM ps_product
WHERE id_category_default = 2 AND price = 0 AND redirect_type = ' ' AND state = 0
ORDER BY id_product DESC;

After creating the query, just click view to see if any products match it. If products match, you probably want to delete these products. Sadly, PS does not allow a delete query in BackOffice (or at least not as far as I know and understand).

So to delete the products (if any), login to your database interface, which is probably phpMyAdmin or something simular. Click SQL and execute the query below:

DELETE FROM ps_product
WHERE id_category_default = 2 AND price = 0 AND redirect_type = ' ' AND state = 0;

 

Hope it helps..

Cheers!

Link to comment
Share on other sites

  • 11 months later...
On 10/21/2019 at 10:56 AM, dsolsona said:

Hi,

I've this problem at Prestashop 1.7.6.1. 

Is not fixed yet?

 

David

Hi David,

I guess not. I also still had the problem. I've written a small script as a work around. Here it is:

<?php
$servername = "localhost";
$username = "***";
$password = "***";
$dbname = "***";

$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 

$sql = "DELETE FROM ps_product WHERE id_category_default = 2 AND price = 0 AND redirect_type = ' ' AND state = 0";

if ($conn->query($sql) === TRUE) {
    echo "Products cleaned up successfully";
} else {
    echo "Error: " . $conn->error;
}

$conn->close();
?>

Just replace the *** with respective DB username, password and name and save the script via FTP.
Next you can call the script manually on it's location or via cronjob.

For example: I have the script in  rootfolder/crons/clean-products.php.
And I have a cronjob calling mywebsite.com/crons/clean-products.php every night.
And if needed I can always call the script manually during the day.

 

Hope this helps.

 

Cheers

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

  • 4 years later...

I resolved the issue by modifying the Product.php class. In the save() method, I added $this->active = 0;. This line ensures that the product is created as inactive by default and won't appear in the front office. It will only appear once the product's options are updated and 'active' is manually enabled from the back office.

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...