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

[DOC] Update filter code exemple for uptodate and fonctionnal code #5525

Open
Yivan opened this issue Jan 4, 2020 · 3 comments
Open

[DOC] Update filter code exemple for uptodate and fonctionnal code #5525

Yivan opened this issue Jan 4, 2020 · 3 comments

Comments

@Yivan
Copy link
Contributor

@Yivan Yivan commented Jan 4, 2020

Hello,

This issue is about adapting the e-commerce filter documentation for working/easier implementation.

1- Controller part

This section of documentation seems outdated and don't work:
https://pimcore.com/docs/6.x/Development_Documentation/E-Commerce_Framework/Filter_Service/index.html#page_3-Putting-it-all-together

For instance, getting parameters use the old way:
$this->getParam('page')``should be $request->get('page')`

It seems $this->view don't work well no more (from my test) and we must use a view model instancied $viewModel = new \Pimcore\Templating\Model\ViewModel();. I found the way to do it by diging into the demo exemple controller (https://github.com/pimcore/demo/blob/master/src/AppBundle/Controller/ProductController.php#L121)

And for better comprehension namespaces should be included (for instance $factory = \Pimcore\Bundle\EcommerceFrameworkBundle\Factory::getInstance();`` instead of $factory = Factory::getInstance();

In fact the code provided in the demo (https://github.com/pimcore/demo/blob/master/src/AppBundle/Controller/ProductController.php#L119) seems working and fonctionnal with latest Pimcore/Symfony so I think this part of code in the doc should be updated/corrected. A link to this demo controller could be added too.

2- View part

For the view part, https://pimcore.com/docs/6.x/Development_Documentation/E-Commerce_Framework/Filter_Service/index.html#page_View , maybe twig exemple could be added (like you have done it on some other parts of documentations).

Thanks.

@PimLab

This comment has been minimized.

Copy link
Contributor

@PimLab PimLab commented Jan 5, 2020

Hey @Yivan

for 2 - View Part this must be the solution:

{% if filterDefinitionObject.getFilters() is not empty %}
<div class="widget">
    {% for filter in filterDefinitionObject.getFilters() %}
        {{ filterService.getFilterFrontend(filter, products, currentFilter) }}
    {% endfor %}
</div>
{% endif %}

Feel free to add it to the documentation by yourself :-)

Best Whishes

@Yivan

This comment has been minimized.

Copy link
Contributor Author

@Yivan Yivan commented Jan 6, 2020

@PimLab
Thanks for this code snippet!
It should be added to documentation yes.

@fashxp

This comment has been minimized.

Copy link
Member

@fashxp fashxp commented Jan 7, 2020

we appreciate every contribution to the docs. and it would be even less effort to change the docs directly ;-)
thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.