When trying to save a grouped product we get this error message
Column not found: 1054 Unknown column 'position' in 'order clause'
And the query is
SELECT
`e`.*, `at_inventory_in_stock`.`is_in_stock` AS `inventory_in_stock` ,
`at_status`.`value` AS `status` ,
`links`.`link_id`
FROM
`catalog_product_entity` AS `e`
INNER JOIN `cataloginventory_stock_item` AS `at_inventory_in_stock` ON(
at_inventory_in_stock.`product_id` = e.entity_id
)
AND(
(
at_inventory_in_stock.use_config_manage_stock = 0
AND at_inventory_in_stock.manage_stock = 1
AND at_inventory_in_stock.is_in_stock = 1
)
OR(
at_inventory_in_stock.use_config_manage_stock = 0
AND at_inventory_in_stock.manage_stock = 0
)
OR(
at_inventory_in_stock.use_config_manage_stock = 1
AND at_inventory_in_stock.is_in_stock = 1
)
)
INNER JOIN `catalog_product_entity_int` AS `at_status` ON(
`at_status`.`entity_id` = `e`.`entity_id`
)
AND(
`at_status`.`attribute_id` = '96'
)
AND(`at_status`.`store_id` = 0)
INNER JOIN `catalog_product_link` AS `links` ON links.linked_product_id = e.entity_id
AND links.link_type_id = 3
WHERE
(
(
(`e`.`required_options` != 1)
OR(`e`.`required_options` IS NULL)
)
)
AND(at_status. VALUE IN(1 , 2))
AND(links.product_id = 16815)
AND(`e`.`entity_id` != '16815')
ORDER BY
`position` ASC
We trace the clause to class
Magento\Catalog\Model\ResourceModel\Product\Link\Product\Collection
and the method
/**
* Enable sorting products by its position
*
* @param string $dir sort type asc|desc
* @return $this
*/
public function setPositionOrder($dir = self::SORT_ORDER_ASC)
{
if ($this->_hasLinkFilter) {
$this->getSelect()->order('position ' . $dir);
}
return $this;
}
We can't find any table referenced in the query with a position column.
Hello, @licentia ! I can create grouped product successfully by web interface. Could you clarify steps to reproduce?
I don't have that installation anymore, but the error happened in a installation with migrated content.
So, you don't have this issue?
I had. Now I don't because I removed that installation.
So, we can closed the issue?
Yes
Thank you!
I am getting same error message while saving a grouped product:- Column not found: 1054 Unknown column 'position' in 'order clause'
SELECT e.*, at_status.value AS status, links.link_id FROM catalog_product_entity AS e INNER JOIN catalog_product_entity_int AS at_status ON (at_status.entity_id = e.entity_id) AND (at_status.attribute_id = '97') AND (at_status.store_id = 0) INNER JOIN catalog_product_link AS links ON links.linked_product_id = e.entity_id AND links.link_type_id = 3 INNER JOIN catalog_product_entity AS product_entity_table ON links.product_id = product_entity_table.entity_id WHERE (((e.required_options != 1) OR (e.required_options IS NULL))) AND (at_status.value IN(1, 2)) AND (links.product_id = 318) AND (e.entity_id != '318') ORDER BY position ASC
Magento version: 2.1.2
This issue is fixed now. Unfortunately I had truncated catalog_product_link_attribute table, while removing all products and categories from database as mentioned on stackoverflow (http://magento.stackexchange.com/a/102995/14787). I have inserted following records on that table and it fixed the issue.
INSERT INTO catalog_product_link_attribute VALUES (1,1,'position','int'),(2,4,'position','int'),(3,5,'position','int'),(4,3,'position','int'),(5,3,'qty','decimal');
sumanta-cn you saved me. I did the exact same thing (deleted from that table while clearing out the db). Thanks for providing the insert script also.
@sumanta-cn, Thanks! You saved my time .
Most helpful comment
This issue is fixed now. Unfortunately I had truncated
catalog_product_link_attributetable, while removing all products and categories from database as mentioned on stackoverflow (http://magento.stackexchange.com/a/102995/14787). I have inserted following records on that table and it fixed the issue.INSERT INTO
catalog_product_link_attributeVALUES (1,1,'position','int'),(2,4,'position','int'),(3,5,'position','int'),(4,3,'position','int'),(5,3,'qty','decimal');