Forums › Forums › OroCommerce › Add custom Button above Products datagrid buttons container
This topic contains 3 replies, has 2 voices, and was last updated by mlozynskyy 6 years, 7 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- August 30, 2017 at 7:25 am #32055
Hello,
How can I add custom button above products grid
orocommerce/vendor/oro/commerce/src/Oro/Bundle/ProductBundle/Resources/views/Product/index.html.twigblock navButtons
How can I override this block?
- CreatorTopic
- AuthorReplies
- August 30, 2017 at 9:33 am #32056
Hello, mlozynskyy.
You can use functionality of placeholders. Add new configuration for placeholder to ‘Resources/config/oro/placeholders.yml’ of you bundle. You can use placeholder named ‘index_navButtons_before’.
Example configuration of placeholders.yml:
YAML123456789placeholders:placeholders:index_navButtons_before:items:some_button: ~items:some_button:template: AcmeBundle:Button:button.html.twigOf cource you should implement twig template for your button.
This placeholder will be rendered in template https://github.com/oroinc/platform/blob/master/src/Oro/Bundle/UIBundle/Resources/views/actions/index.html.twig#L26.As alternative solution you can use functionality of ActionBundle. You need to implement operation with your requirements and in configuration use needed route. Examples you can find in ‘Resources/config/oro/actions.yml’ in bundles of OroPlatform, OroCommerce and OroCRM.
August 30, 2017 at 3:22 pm #32057@msulima Thank You
It works.But I cant filter pages for showing my button:
it is my code:PHP12345678910111213placeholders:placeholders:index_navButtons_before:items:product_price_import_button:order: 10items:product_price_import_button:template: WwImportBundle:placeholders/Product:priceImportButton.html.twigapplicable:- "@oro_ui.placeholder.filter->isInstanceOf($entity$, %oro_product.entity.product.class%)"#Not working for product datagridgrid page - "@oro_frontend.placeholder.filter->isBackendRoute()"August 30, 2017 at 3:55 pm #32058I have written a custom filter and use it in placeholder file:
PHP12345678910111213141516171819202122232425262728293031323334/*** Class FrontendFilter*/class FrontendFilter{/*** @var RequestStack*/protected $requestStack;/*** @param RequestStack $requestStack*/public function __construct(RequestStack $requestStack){$this->requestStack = $requestStack;}/*** @param string $route* @return bool*/public function isDataGridRoute($route){$request = $this->requestStack->getCurrentRequest();if ($request->get('_route') === $route) {return true;}return false;}} - AuthorReplies
The forum ‘OroCommerce’ is closed to new topics and replies.