Skip to content

Instantly share code, notes, and snippets.

@programgames
Created November 26, 2021 13:24
Show Gist options
  • Save programgames/17fcfcb79a5f38ce9927242045e71ac0 to your computer and use it in GitHub Desktop.
Save programgames/17fcfcb79a5f38ce9927242045e71ac0 to your computer and use it in GitHub Desktop.
DQL in oro datagrid
frontend-customer-user-shopping-list-grid:
source:
type: orm
query:
select:
- name.string AS productName
- >
(
SELECT parent1.left FROM \Oro\Bundle\CatalogBundle\Entity\Category parent1
WHERE parent1.id = (
SELECT CAST(SUBSTRING(child1.materializedPath, '(?<=\d+_)\d+(?<=_.*)') AS INT)
FROM \Oro\Bundle\CatalogBundle\Entity\Category child1
WHERE child1.id = category.id
)
) as parentLeft
- >
(
SELECT parent2.right FROM \Oro\Bundle\CatalogBundle\Entity\Category parent2
WHERE parent2.id = (
SELECT CAST(SUBSTRING(child2.materializedPath, '(?<=\d+_)\d+(?<=_.*)') AS INT)
FROM \Oro\Bundle\CatalogBundle\Entity\Category child2
WHERE child2.id = category.id
)
) as parentRight
join:
left:
- { join: product.category, alias: category }
- { join: product.names, alias: name }
orderBy:
- column: parentLeft
dir: asc
- column: parentRight
dir: asc
- column: productName
dir: asc
columns:
item:
label: oro.frontend.shoppinglist.lineitem.item.label
frontend_type: shoppinglist-item
frontend_template: tpl-loader!mybundle/templates/datagrid/cell/item.html
image_placeholder: "@oro_product.provider.product_image_placeholder->getPath('product_small')"
inventory_statuses: "@oro_product.provider.product_inventory_status_provider->getAvailableProductInventoryStatuses()"
productName:
renderable: false
label: productName
categories:
renderable: false
frontend_type: html
type: twig
template: MyBundle:Datagrid:category.html.twig
data_name: sku
sorters:
disable_default_sorting: true
options:
toolbarOptions:
pagination:
onePage: true
pageSize:
default_per_page: 1000000
items:
- 1000000
frontend-product-search-grid:
sorters:
columns:
names:
data_name: string.names
disable_default_sorting: false
default:
names: ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment