Jump to content

Problem with SQL SELECT code - Help...


nik_slick

Recommended Posts

Hello there!

 

I am more or less a newbie when it comes to MySQL. So please have patience. :)

 

We have a webshop where all products come from separate suppliers with a script that automatically unpublishes products that the supplier no longer has in it's offer. However, as we have several suppliers, running one script will un-publish all others and also the products that we have locally (which in turn might have been discontinued by supplier, but since we have them, we wish to sell them).

 

What we have done now, is added an attribute to the system with a code for the supplier. However, I can't get the code to work. The original code which updated all products no matter what works, but I need help inserting the final bit.

 

This is the code that works. It creates a table with sku inserted from three variables.

 

$updateunpublished = "INSERT INTO unpublished SELECT sku 
                                            FROM catalog_product_entity 
                                            WHERE entity_id 
                                            NOT IN (
                                            SELECT entity_id 
                                            FROM catalog_product_entity_varchar  
                                            WHERE value = 0 
                                            AND attribute_id = 947) 
                                            AND sku 
                                            NOT IN (
                                            SELECT item 
                                            FROM csvupdate) 
                                            AND sku 
                                            NOT IN (
                                            SELECT sku 
                                            FROM unpublished);";

 

What I need is to insert a new variable that checks the supplier is correct, otherwise it should not include that product in the un-publish list. The attribute_id is "xxx" and the value should be "bbb" and the table it should pick it from is catalog_product_entity_int.

 

I am completely lost, as I am a newbie at this. The code above was done by someone else and it's probably dead easy.

 

Anyone - help... ;)

 

//Nik

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.