@@ -483,28 +483,32 @@ protected function _updateAttributeOption($object, $optionId, $option)
483
483
* @param int $optionId
484
484
* @return void
485
485
*/
486
- private function clearSelectedOptionInEntities ($ object , $ optionId )
486
+ private function clearSelectedOptionInEntities (AbstractModel $ object , int $ optionId )
487
487
{
488
488
$ backendTable = $ object ->getBackendTable ();
489
489
$ attributeId = $ object ->getAttributeId ();
490
490
if (!$ backendTable || !$ attributeId ) {
491
491
return ;
492
492
}
493
493
494
- $ where = 'attribute_id = ' . $ attributeId ;
494
+ $ connection = $ this ->getConnection ();
495
+ $ where = $ connection ->quoteInto ('attribute_id = ? ' , $ attributeId );
495
496
$ update = [];
496
497
497
498
if ($ object ->getBackendType () === 'varchar ' ) {
498
- $ where .= " AND FIND_IN_SET(' $ optionId',value) " ;
499
- $ update ['value ' ] = new \Zend_Db_Expr (
500
- "TRIM(BOTH ',' FROM REPLACE(CONCAT(',',value,','),', $ optionId,',',')) "
499
+ $ where .= ' AND ' . $ connection ->prepareSqlCondition ('value ' , ['finset ' => $ optionId ]);
500
+ $ concat = $ connection ->getConcatSql (["',' " , 'value ' , "',' " ]);
501
+ $ expr = $ connection ->quoteInto (
502
+ "TRIM(BOTH ',' FROM REPLACE( $ concat,',?,',',')) " ,
503
+ $ optionId
501
504
);
505
+ $ update ['value ' ] = new \Zend_Db_Expr ($ expr );
502
506
} else {
503
- $ where .= ' AND value = ' . $ optionId ;
507
+ $ where .= $ connection -> quoteInto ( ' AND value = ? ' , $ optionId) ;
504
508
$ update ['value ' ] = null ;
505
509
}
506
510
507
- $ this -> getConnection () ->update ($ backendTable , $ update , $ where );
511
+ $ connection ->update ($ backendTable , $ update , $ where );
508
512
}
509
513
510
514
/**
0 commit comments