Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Fix working with mssql
Browse files Browse the repository at this point in the history
  • Loading branch information
wbloszyk committed May 14, 2020
1 parent cee53e4 commit 255db90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,14 @@ public function registerDoctrineMapping(array $config): void
'targetEntity' => $config['class']['product'],
'cascade' => [
'persist',
'remove',
],
'mappedBy' => null,
'inversedBy' => 'variations',
'joinColumns' => [
[
'name' => 'parent_id',
'referencedColumnName' => 'id',
'onDelete' => 'CASCADE',
],
],
'orphanRemoval' => false,
Expand Down
10 changes: 6 additions & 4 deletions src/ProductBundle/Entity/ProductCategoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public function getProductCount(CategoryInterface $category, $limit = 1000)
LEFT JOIN %s p ON pc.product_id = p.id
LEFT JOIN %s c ON pc.category_id = c.id
LEFT JOIN %s p2 ON p.id = p2.parent_id
WHERE p.enabled = :enabled
AND (p2.enabled = :enabled OR p2.enabled IS NULL)
AND (c.enabled = :enabled OR c.enabled IS NULL)
WHERE p.enabled = :productEnabled
AND (p2.enabled = :parentEnabled OR p2.enabled IS NULL)
AND (c.enabled = :categoryEnabled OR c.enabled IS NULL)
AND p.parent_id IS NULL
AND pc.category_id = :categoryId
LIMIT %d
Expand All @@ -107,7 +107,9 @@ public function getProductCount(CategoryInterface $category, $limit = 1000)
$sql = sprintf($sql, $metadata->table['name'], $productMetadata->table['name'], $categoryMetadata->table['name'], $productMetadata->table['name'], $limit);

$statement = $this->getConnection()->prepare($sql);
$statement->bindValue('enabled', 1);
$statement->bindValue('productEnabled', 1);
$statement->bindValue('parentEnabled', 1);
$statement->bindValue('categoryEnabled', 1);
$statement->bindValue('categoryId', $category->getId());

$statement->execute();
Expand Down

0 comments on commit 255db90

Please sign in to comment.