Jump to content

Edit History

knacky

knacky

Here's a working solution:

public function hookActionOrderGridQueryBuilderModifier(array $params)
    {

        $searchQueryBuilder = $params['search_query_builder'];

        $searchCriteria = $params['search_criteria'];

        $searchQueryBuilder->addSelect(
            'cu.`agecheck` AS `agecheck`'
        );

        if ('agecheck' === $searchCriteria->getOrderBy()) {
            $searchQueryBuilder->orderBy('cu.`agecheck`', $searchCriteria->getOrderWay());
        }

        foreach ($searchCriteria->getFilters() as $filterName => $filterValue) {
            if ('agecheck' === $searchCriteria->getOrderBy()) {
                $searchQueryBuilder->orderBy('cu.`agecheck`', $searchCriteria->getOrderWay());
            }

            if ($filterName === 'agecheck') {
                $searchQueryBuilder->andWhere("cu.`agecheck` = :agecheck");
                $searchQueryBuilder->setParameter('agecheck', $filterValue);
            }
        }
    }

    public function hookActionOrderGridDefinitionModifier(array $params)
    {
        $definition = $params['definition'];
        
        $definition->getColumns()
            ->addAfter('reference', (new StatusColumn('agecheck'))->setName($this->l('18 ?'))
            ->setOptions(
                ['field' => 'agecheck',]
            )
        );

        $definition->getFilters()->add((new Filter('agecheck', YesAndNoChoiceType::class))
            ->setAssociatedColumn('agecheck')
            ->setTypeOptions([
                'required' => false,
            ])
        );
    }

 

knacky

knacky

Here's a working solution:

 public function hookActionOrderGridQueryBuilderModifier(array $params)
    {

        $searchQueryBuilder = $params['search_query_builder'];

        $searchCriteria = $params['search_criteria'];

        $searchQueryBuilder->addSelect(
            'cu.`agecheck` AS `agecheck`'
        );

        if ('agecheck' === $searchCriteria->getOrderBy()) {
            $searchQueryBuilder->orderBy('cu.`agecheck`', $searchCriteria->getOrderWay());
        }
        foreach ($searchCriteria->getFilters() as $filterName => $filterValue) {
            if($filterValue != null || $filterValue != '') {
                if ('cagecheck' === $filterName) {
                    $searchQueryBuilder->andWhere('cu.`agecheck` = :agecheck');
                    $searchQueryBuilder->setParameter('agecheck', $filterValue);
                }
            }
        }
    }

    public function hookActionOrderGridDefinitionModifier(array $params)
    {
        $definition = $params['definition'];
        
        $definition->getColumns()
            ->addAfter('reference', (new StatusColumn('agecheck'))->setName($this->l('18 ?'))
            ->setOptions(
                ['field' => 'agecheck',]
            )
        );

        $definition->getFilters()->add((new Filter('agecheck', YesAndNoChoiceType::class))
            ->setAssociatedColumn('agecheck')
            ->setTypeOptions([
                'required' => false,
            ])
        );
    }

 

knacky

knacky

public function hookActionAdminOrdersListingFieldsModifier($params)
{
    if (isset($params['select'])) {
        $params['select'] .= 'c.agecheck as `agecheck`';
    }

    if (isset($params['join'])) {
        $params['join'] .= 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (a.`id_customer` = c.`id_customer`)';
    }

    $params['fields']['agecheck'] = [
        'title' => $this->l('18 ?'),
        'type' => 'boolean',
        'align' => 'text-center',
        'class' => 'fixed-width-xl',
        'filter_type' => 'boolean',
    ];
}

public function hookActionOrderGridDefinitionModifier(array $params)
{

    $definition = $params['definition'];

    $filters = $definition->getFilters();

    $columns = $definition->getColumns();

    $columns
        ->addAfter('id_order',
            (new DataColumn('agecheck'))
                ->setName($this->l('18 ?'))
                ->setOptions([
                    'field' => 'agecheck',
                ])
        );
}

 

knacky

knacky

public function hookActionAdminOrdersListingFieldsModifier($params)
{
    if (isset($params['select'])) {
        $params['select'] .= 'c.agecheck as `agecheck`';
    }

    if (isset($params['join'])) {
        $params['join'] .= 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (a.`id_customer` = oc.`id_customer`)';
    }

    $params['fields']['agecheck'] = [
        'title' => $this->l('18 ?'),
        'type' => 'boolean',
        'align' => 'text-center',
        'class' => 'fixed-width-xl',
        'filter_type' => 'boolean',
    ];
}

public function hookActionOrderGridDefinitionModifier(array $params)
{

    $definition = $params['definition'];

    $filters = $definition->getFilters();

    $columns = $definition->getColumns();

    $columns
        ->addAfter('id_order',
            (new DataColumn('agecheck'))
                ->setName($this->l('18 ?'))
                ->setOptions([
                    'field' => 'agecheck',
                ])
        );
}

 

knacky

knacky

public function hookActionAdminOrdersListingFieldsModifier($params)
{
    if (isset($params['select'])) {
        $params['select'] .= 'c.agecheck as `agecheck`';
    }

    if (isset($params['join'])) {
        $params['join'] .= 'LEFT JOIN `'._DB_PREFIX_.'customer` c ON (a.`id_customer` = oc.`id_customer`)';
    }

    $params['fields']['agecheck'] = [
        'title' => $this->l('18 ?'),
        'type' => 'boolean',
        'align' => 'text-center',
        'class' => 'fixed-width-xl',
        'filter_type' => 'boolean',
    ];
}

public function hookActionOrderGridDefinitionModifier(array $params)
{

    $definition = $params['definition'];

    $filters = $definition->getFilters();

    $columns = $definition->getColumns();

    $columns
        ->addAfter('country_name',
            (new DataColumn('agecheck'))
                ->setName($this->l('18 ?'))
                ->setOptions([
                    'field' => 'agecheck',
                ])
        );
}

 

×
×
  • Create New...