Siva
Siva

Reputation: 509

Invoke extbase repository in another extension

I am working with 2 extbase extensions products and applications. In products extension I have created TCA's for product and its categories.And in products extension everything is working as intended.

I would like to use the product repository in applications extension . I used the below code and it is working fine, only for corresponding pages. My requirement is that I would like to use the same repository (products repository) with out respecting the pages ids.

/**
 * productsRepository
 *
 * @var \VENDOR\Products\Domain\Repository\ProductsRepository
 * @inject
 */
protected ProductsRepository = NULL;

I could use the below code but AFIK it would work only for applications extension

$query->getQuerySettings()->setRespectStoragePage(FALSE);

Can any one help me to find a solution for this ?

PS:I haven't added any model or repository for application extension

Upvotes: 0

Views: 744

Answers (1)

biesior
biesior

Reputation: 55798

In your product ProductsRepository you can override the initializeObject() method:

public function initializeObject() {
    /** @var $querySettings \TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface */
    $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
    $querySettings->setRespectStoragePage(FALSE);
    $this->setDefaultQuerySettings($querySettings);
}

It will affect all queries of the repository, nevermind where are they called from.

Upvotes: 1

Related Questions