Magento 2 - Hide Products with no Images via PHP SQL QueryHow to make SQL query with MagentoComplex SQL query to MagentoUpdate weight through sql queryHelp building an SQL query for products with custom optionsConvert SQL Select to Magento SQL queryMagento SQL Insert query is not working and shows no errorssql to query to Magento querySql Query Not Working in DBSQL Query for gettin all products with custom optionsSlow SQL query with many joins

Parse a C++14 integer literal

Is being an extrovert a necessary condition to be a manager?

Is there any official Lore on Keraptis the Wizard, apart from what is in White Plume Mountain?

How was the blinking terminal cursor invented?

Cycling to work - 30 mile return

Precedent for disabled Kings

Latin words remembered from high school 50 years ago

Germany rejected my entry to Schengen countries

How to plot a surface from a system of equations?

Why would Thor need to strike a building with lightning to attack enemies?

Have the writers and actors of Game Of Thrones responded to its poor reception?

Why didn't Daenerys' advisers suggest assassinating Cersei?

Can the bitcoin lightning network support more than 8 decimal places?

What were the "pills" that were added to solid waste in Apollo 7?

Is it a good idea to teach algorithm courses using pseudocode instead of a real programming language?

Addressing an email

How do you cope with rejection?

Why is python script running in background consuming 100 % CPU?

Isn't Kirchhoff's junction law a violation of conservation of charge?

How to choose the correct exposure for flower photography?

Hotel booking: Why is Agoda much cheaper than booking.com?

Why does string strummed with finger sound different from the one strummed with pick?

In How Many Ways Can We Partition a Set Into Smaller Subsets So The Sum of the Numbers In Each Subset Is Equal?

Bash Array of Word-Splitting Headaches



Magento 2 - Hide Products with no Images via PHP SQL Query


How to make SQL query with MagentoComplex SQL query to MagentoUpdate weight through sql queryHelp building an SQL query for products with custom optionsConvert SQL Select to Magento SQL queryMagento SQL Insert query is not working and shows no errorssql to query to Magento querySql Query Not Working in DBSQL Query for gettin all products with custom optionsSlow SQL query with many joins






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have an SQL query that i run on the database manually which checks the catalogue for products that do not have an image and hides them, i want to run this via cron so have created a php with the following content:



 <?php 

$servername = "localhost";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";

// Create connection
$conn = new mysqli($servername, $username, $password,$dbname);

// Check connection
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);


// Script to run

$sql=

update catalog_product_entity_int m;
left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
set value = 2
where
a.attribute_code = 'status'
and m.entity_id in
(
select m.entity_id
from catalog_product_entity m
left join catalog_product_entity_media_gallery_value_to_entity a
on a.entity_id = m.entity_id
where a.value_id is null
)
;

if ($conn->query($sql) === TRUE)
echo "Record updated successfully";
else
echo "Error updating record: " . $conn->error;


$conn->close();

?>


But I get this error: [PHP Parse error: syntax error, unexpected 'catalog_product_entity_int' (T_STRING) in /home/public_html/modimages/hideimages.php on line 20



The query works fine when i put it directly on phpmyadmin so i am guessing i am missing something very simple.










share|improve this question




























    0















    I have an SQL query that i run on the database manually which checks the catalogue for products that do not have an image and hides them, i want to run this via cron so have created a php with the following content:



     <?php 

    $servername = "localhost";
    $username = "xxx";
    $password = "xxx";
    $dbname = "xxx";

    // Create connection
    $conn = new mysqli($servername, $username, $password,$dbname);

    // Check connection
    if ($conn->connect_error)
    die("Connection failed: " . $conn->connect_error);


    // Script to run

    $sql=

    update catalog_product_entity_int m;
    left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
    set value = 2
    where
    a.attribute_code = 'status'
    and m.entity_id in
    (
    select m.entity_id
    from catalog_product_entity m
    left join catalog_product_entity_media_gallery_value_to_entity a
    on a.entity_id = m.entity_id
    where a.value_id is null
    )
    ;

    if ($conn->query($sql) === TRUE)
    echo "Record updated successfully";
    else
    echo "Error updating record: " . $conn->error;


    $conn->close();

    ?>


    But I get this error: [PHP Parse error: syntax error, unexpected 'catalog_product_entity_int' (T_STRING) in /home/public_html/modimages/hideimages.php on line 20



    The query works fine when i put it directly on phpmyadmin so i am guessing i am missing something very simple.










    share|improve this question
























      0












      0








      0








      I have an SQL query that i run on the database manually which checks the catalogue for products that do not have an image and hides them, i want to run this via cron so have created a php with the following content:



       <?php 

      $servername = "localhost";
      $username = "xxx";
      $password = "xxx";
      $dbname = "xxx";

      // Create connection
      $conn = new mysqli($servername, $username, $password,$dbname);

      // Check connection
      if ($conn->connect_error)
      die("Connection failed: " . $conn->connect_error);


      // Script to run

      $sql=

      update catalog_product_entity_int m;
      left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
      set value = 2
      where
      a.attribute_code = 'status'
      and m.entity_id in
      (
      select m.entity_id
      from catalog_product_entity m
      left join catalog_product_entity_media_gallery_value_to_entity a
      on a.entity_id = m.entity_id
      where a.value_id is null
      )
      ;

      if ($conn->query($sql) === TRUE)
      echo "Record updated successfully";
      else
      echo "Error updating record: " . $conn->error;


      $conn->close();

      ?>


      But I get this error: [PHP Parse error: syntax error, unexpected 'catalog_product_entity_int' (T_STRING) in /home/public_html/modimages/hideimages.php on line 20



      The query works fine when i put it directly on phpmyadmin so i am guessing i am missing something very simple.










      share|improve this question














      I have an SQL query that i run on the database manually which checks the catalogue for products that do not have an image and hides them, i want to run this via cron so have created a php with the following content:



       <?php 

      $servername = "localhost";
      $username = "xxx";
      $password = "xxx";
      $dbname = "xxx";

      // Create connection
      $conn = new mysqli($servername, $username, $password,$dbname);

      // Check connection
      if ($conn->connect_error)
      die("Connection failed: " . $conn->connect_error);


      // Script to run

      $sql=

      update catalog_product_entity_int m;
      left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
      set value = 2
      where
      a.attribute_code = 'status'
      and m.entity_id in
      (
      select m.entity_id
      from catalog_product_entity m
      left join catalog_product_entity_media_gallery_value_to_entity a
      on a.entity_id = m.entity_id
      where a.value_id is null
      )
      ;

      if ($conn->query($sql) === TRUE)
      echo "Record updated successfully";
      else
      echo "Error updating record: " . $conn->error;


      $conn->close();

      ?>


      But I get this error: [PHP Parse error: syntax error, unexpected 'catalog_product_entity_int' (T_STRING) in /home/public_html/modimages/hideimages.php on line 20



      The query works fine when i put it directly on phpmyadmin so i am guessing i am missing something very simple.







      magento2 php sql






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 13 at 15:00









      Mehdi RafiaiMehdi Rafiai

      111117




      111117




















          1 Answer
          1






          active

          oldest

          votes


















          1














          You missed the quotes (") in variable $sql. Try the below one.



          $sql= "update catalog_product_entity_int m
          left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
          set value = 2
          where
          a.attribute_code = 'status'
          and m.entity_id in
          (
          select m.entity_id
          from catalog_product_entity m
          left join catalog_product_entity_media_gallery_value_to_entity a
          on a.entity_id = m.entity_id
          where a.value_id is null
          )";





          share|improve this answer























          • Worked perfectly, thank you!

            – Mehdi Rafiai
            May 13 at 15:55











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f274379%2fmagento-2-hide-products-with-no-images-via-php-sql-query%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You missed the quotes (") in variable $sql. Try the below one.



          $sql= "update catalog_product_entity_int m
          left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
          set value = 2
          where
          a.attribute_code = 'status'
          and m.entity_id in
          (
          select m.entity_id
          from catalog_product_entity m
          left join catalog_product_entity_media_gallery_value_to_entity a
          on a.entity_id = m.entity_id
          where a.value_id is null
          )";





          share|improve this answer























          • Worked perfectly, thank you!

            – Mehdi Rafiai
            May 13 at 15:55















          1














          You missed the quotes (") in variable $sql. Try the below one.



          $sql= "update catalog_product_entity_int m
          left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
          set value = 2
          where
          a.attribute_code = 'status'
          and m.entity_id in
          (
          select m.entity_id
          from catalog_product_entity m
          left join catalog_product_entity_media_gallery_value_to_entity a
          on a.entity_id = m.entity_id
          where a.value_id is null
          )";





          share|improve this answer























          • Worked perfectly, thank you!

            – Mehdi Rafiai
            May 13 at 15:55













          1












          1








          1







          You missed the quotes (") in variable $sql. Try the below one.



          $sql= "update catalog_product_entity_int m
          left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
          set value = 2
          where
          a.attribute_code = 'status'
          and m.entity_id in
          (
          select m.entity_id
          from catalog_product_entity m
          left join catalog_product_entity_media_gallery_value_to_entity a
          on a.entity_id = m.entity_id
          where a.value_id is null
          )";





          share|improve this answer













          You missed the quotes (") in variable $sql. Try the below one.



          $sql= "update catalog_product_entity_int m
          left join eav_attribute a on a.entity_type_id = 4 and a.attribute_id = m.attribute_id
          set value = 2
          where
          a.attribute_code = 'status'
          and m.entity_id in
          (
          select m.entity_id
          from catalog_product_entity m
          left join catalog_product_entity_media_gallery_value_to_entity a
          on a.entity_id = m.entity_id
          where a.value_id is null
          )";






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 13 at 15:27









          Bilal UseanBilal Usean

          5,32544094




          5,32544094












          • Worked perfectly, thank you!

            – Mehdi Rafiai
            May 13 at 15:55

















          • Worked perfectly, thank you!

            – Mehdi Rafiai
            May 13 at 15:55
















          Worked perfectly, thank you!

          – Mehdi Rafiai
          May 13 at 15:55





          Worked perfectly, thank you!

          – Mehdi Rafiai
          May 13 at 15:55

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f274379%2fmagento-2-hide-products-with-no-images-via-php-sql-query%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

          Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

          Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?