Skip to content

Commit

Permalink
Merge pull request #13 from netgen-layouts/fix-disabled-products
Browse files Browse the repository at this point in the history
Don't show products which are disabled
  • Loading branch information
emodric authored Jan 26, 2024
2 parents b6627a2 + c1ab34c commit c92abb3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Item/ValueConverter/ProductValueConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getName(object $object): string

public function getIsVisible(object $object): bool
{
return true;
return $object->isEnabled();
}

public function getObject(object $object): ProductInterface
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Item/Stubs/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

final class Product extends BaseProduct
{
public function __construct(int $id, string $name, ?string $slug = null)
public function __construct(int $id, string $name, ?string $slug = null, bool $enabled = true)
{
parent::__construct();

$this->id = $id;

$this->currentLocale = 'en';
$this->setName($name);

$this->setSlug($slug);
$this->setEnabled($enabled);
}
}
9 changes: 9 additions & 0 deletions tests/lib/Item/ValueConverter/ProductValueConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ public function testGetIsVisible(): void
);
}

public function testGetIsVisibleReturnsFalse(): void
{
self::assertFalse(
$this->valueConverter->getIsVisible(
new ProductStub(42, 'Product name', null, false),
),
);
}

public function testGetObject(): void
{
$product = new ProductStub(42, 'Product name');
Expand Down

0 comments on commit c92abb3

Please sign in to comment.