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;
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
add a comment |
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
add a comment |
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
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
magento2 php sql
asked May 13 at 15:00
Mehdi RafiaiMehdi Rafiai
111117
111117
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
)";
Worked perfectly, thank you!
– Mehdi Rafiai
May 13 at 15:55
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
)";
Worked perfectly, thank you!
– Mehdi Rafiai
May 13 at 15:55
add a comment |
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
)";
Worked perfectly, thank you!
– Mehdi Rafiai
May 13 at 15:55
add a comment |
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
)";
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
)";
answered May 13 at 15:27
Bilal UseanBilal Usean
5,32544094
5,32544094
Worked perfectly, thank you!
– Mehdi Rafiai
May 13 at 15:55
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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