Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get all categories in category tree form (not only enabled ones) #15030

Merged
merged 4 commits into from Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/Adapter/Form/ChoiceProvider/CategoryTreeChoiceProvider.php
Expand Up @@ -44,22 +44,29 @@ final class CategoryTreeChoiceProvider implements FormChoiceProviderInterface
*/
private $contextShopRootCategoryId;

/**
* @var boolean
*/
private $enabledCategoriesOnly;

/**
* @param CategoryDataProvider $categoryDataProvider
* @param $contextShopRootCategoryId
* @param boolean $enabledCategoriesOnly
*/
public function __construct(CategoryDataProvider $categoryDataProvider, $contextShopRootCategoryId)
public function __construct(CategoryDataProvider $categoryDataProvider, $contextShopRootCategoryId, $enabledCategoriesOnly = false)
eternoendless marked this conversation as resolved.
Show resolved Hide resolved
{
$this->categoryDataProvider = $categoryDataProvider;
$this->contextShopRootCategoryId = $contextShopRootCategoryId;
$this->enabledCategoriesOnly = $enabledCategoriesOnly;
}

/**
* {@inheritdoc}
*/
public function getChoices()
{
$categories = $this->categoryDataProvider->getNestedCategories($this->contextShopRootCategoryId);
$categories = $this->categoryDataProvider->getNestedCategories($this->contextShopRootCategoryId, false, $this->enabledCategoriesOnly);
$choices = [];

foreach ($categories as $category) {
Expand Down
Expand Up @@ -15,6 +15,7 @@ services:
arguments:
- '@prestashop.adapter.data_provider.category'
- '@=service("prestashop.adapter.data_provider.category").getRootCategory().id'
- false

prestashop.adapter.form.choice_provider.gender_by_id_choice_provider:
class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\GenderByIdChoiceProvider'
Expand Down