Hello.
I've upgraded Magento on my dev. site from 2.4.2-p1 to 2.4.3, which went smoothly, but if I click 'Add Product' I get the following error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?))' at line 2, query was: SELECT `e`.`entity_id` FROM `mgxv_catalog_product_super_link` AS `l`
INNER JOIN `mgxv_catalog_product_entity` AS `e` ON e.entity_id = l.parent_id WHERE (l.product_id IN(?))
This is from exception.log:
[2021-08-26 08:57:50] main.CRITICAL: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?))' at line 2, query was: SELECT e.entity_id FROM mgxv_catalog_product_super_link AS l INNER JOIN mgxv_catalog_product_entity AS e ON e.entity_id = l.parent_id WHERE (l.product_id IN(?)) {"report_id":"ec517c5a03ebe3ba0494ab4d33408db992171b57923a4032be36c29afb2bddf6","exception":"[object] (Zend_Db_Statement_Exception(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?))' at line 2, query was: SELECT e.entity_id FROM mgxv_catalog_product_super_link AS l INNER JOIN mgxv_catalog_product_entity AS e ON e.entity_id = l.parent_id WHERE (l.product_id IN(?)) at /public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:110, PDOException(code: 42000): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?))' at line 2 at /public_html/vendor/magento/framework/DB/Statement/Pdo/Mysql.php:91)"} []
Is anyone able to advise what might cause this please?
Solved! Go to Solution.
In my case, it was an Amasty extension that caused the issue, Product Attachments. I reported it to them and they have now fixed the issue for me.
I have the similar issue.
Any idea how to fix it?
Hello I have the same issue, cant add new produts i can only update old products but not duplicate or add produts
Any solution on this??
Yes,
Amasty/ProductAttachment/Model/Product/DataProvider/Modifiers/Meta.php
$isPartOfConfigurable = (bool)$this->configurableProduct->getParentIdsByChild(
$this->locator->getProduct()->getId()
);
Really, you'd need to do a check that the productId actually exists first since you haven't created the product yet
So you could change it to
if(!$this->locator->getProduct()->getId()) return $meta;
$isPartOfConfigurable = (bool)$this->configurableProduct->getParentIdsByChild(
$this->locator->getProduct()->getId()
);
I've just found this thread. For anyone this may help going forward -
I am creating my own module and was getting the same error from my custom Helper.
As said, you need to check that the product id is not null before you get the configurable parent.
$configproductid = $objectManager->create('Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable')->getParentIdsByChild($productid);
This gave me the error:
Syntax error or access violation: 1064 You have an error in your SQL syntax, query was: SELECT `e`.`entity_id` FROM `catalog_product_super_link` AS `l` INNER JOIN `catalog_product_entity` AS `e` ON e.entity_id = l.parent_id WHERE (l.product_id IN(?))
All I needed to do was check if the product id exists beforehand.
$productid = $product->getId();
if ($productid) { $configproductid = $objectManager->create('Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable')->getParentIdsByChild($productid); }
Worked great for me.