getColumnName example


    protected function fetchVersionAndNotUpsertableValues($versionedClass, array $id)
    {
        $columnNames = [];
        foreach ($this->class->fieldMappings as $key => $column) {
            if (isset($column['generated']) || ($this->class->isVersioned && $key === $versionedClass->versionField)) {
                $columnNames[$key] = $this->quoteStrategy->getColumnName($key$versionedClass$this->platform);
            }
        }

        $tableName  = $this->quoteStrategy->getTableName($versionedClass$this->platform);
        $identifier = $this->quoteStrategy->getIdentifierColumnNames($versionedClass$this->platform);

        // FIXME: Order with composite keys might not be correct         $sql = 'SELECT ' . implode(', ', $columnNames)
            . ' FROM ' . $tableName
            . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?';

        


    /** * @return array<array<string, mixed>> */
    private function getAttributeMapping(): array
    {
        $attributes = $this->crudService->getList('s_articles_attributes');

        $properties = [];
        foreach ($attributes as $attribute) {
            $name = $attribute->getColumnName();
            $type = $attribute->getElasticSearchType();

            if ($attribute->isIdentifier()) {
                continue;
            }

            switch ($type['type']) {
                case 'keyword':
                    $type = $this->textMapping->getKeywordField();
                    $type['fields']['raw'] = $this->textMapping->getKeywordField();
                    break;

                
return $data;
    }

    /** * Returns all none association property of the product class. */
    private function getAttributeProperties(): array
    {
        $attributeNames = $this->getContainer()->get(CrudServiceInterface::class)->getList('s_articles_attributes');
        $fields = [];
        foreach ($attributeNames as $property) {
            $fields[] = '__attribute_' . $property->getColumnName();
        }

        return $fields;
    }
}
/** * Returns all none association property of the category class. * * @return string[] */
    private function getAttributeProperties(): array
    {
        $crud = $this->getContainer()->get(CrudServiceInterface::class);
        $list = $crud->getList('s_categories_attributes');
        $fields = [];
        foreach ($list as $property) {
            $fields[] = '__attribute_' . $property->getColumnName();
        }

        return $fields;
    }
}
private function parseAttributes(array $attributes): array
    {
        if (!isset($attributes['core'])) {
            return $attributes;
        }

        if ($this->attributeConfigList === null) {
            $this->attributeConfigList = $this->crudService->getList('s_articles_attributes');
        }

        foreach ($this->attributeConfigList as $attributeConfig) {
            $columnName = $attributeConfig->getColumnName();
            if ($attributes['core']->exists($columnName)) {
                $value = $attributes['core']->get($columnName);

                if ($attributeConfig->getColumnType() === 'boolean') {
                    $value = $value === '1';
                }

                $attributes['core']->set($columnName$value);
            }
        }

        

    public function getSeoArticleQuery()
    {
        $attributesList = Shopware()->Container()->get(CrudServiceInterface::class)->getList('s_articles_attributes');
        $attributes = [];
        foreach ($attributesList as $attribute) {
            if ($attribute->isIdentifier()) {
                continue;
            }
            $attributes[] = 'at.' . $attribute->getColumnName();
        }

        return ' SELECT a.*, d.ordernumber, d.suppliernumber, s.name AS supplier, a.datum AS date, d.releasedate, a.changetime AS changed, ct.objectdata, ctf.objectdata AS objectdataFallback, ' . implode(',', $attributes) . " FROM s_articles a INNER JOIN s_articles_categories_ro ac ON ac.articleID = a.id AND ac.categoryID = ? INNER JOIN s_categories c ON c.id = ac.categoryID AND c.active = 1 JOIN s_articles_details d ON d.id = a.main_detail_id LEFT JOIN s_articles_attributes at ON at.articledetailsID=d.id LEFT JOIN s_core_translations ct ON ct.objectkey=a.id AND ct.objectlanguage=? AND ct.objecttype='article' LEFT JOIN s_core_translations ctf ON ctf.objectkey=a.id AND ctf.objectlanguage=? AND ctf.objecttype='article' LEFT JOIN s_articles_supplier s ON s.id=a.supplierID WHERE a.active=1 AND a.changetime > ? GROUP BY a.id ORDER BY a.changetime, a.id ";
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $metaData = $this->entityManager->getClassMetadata($options['data_class']);

        $attributes = $this->attributeService->getList($metaData->getTableName());

        foreach ($attributes as $attribute) {
            if ($attribute->isIdentifier()) {
                continue;
            }

            $field = $metaData->getFieldForColumn($attribute->getColumnName());
            $builder->add($field);
        }

        // set default value for all attribute fields to prevent null override if a field isn't in the submit data         $builder->addEventListener(FormEvents::POST_SET_DATA, function DFormEvent $event) use ($attributes$metaData) {
            try {
                $form = $event->getForm();
                $data = $event->getData();

                if (!$data instanceof ModelEntity) {
                    return;
                }


    /** * {@inheritdoc} */
    public function get($table$columnName)
    {
        $columnName = $this->formatColumnName($columnName);

        $columns = $this->getList($table);
        foreach ($columns as $column) {
            if ($column->getColumnName() === $columnName) {
                return $column;
            }
        }

        return null;
    }

    /** * {@inheritdoc} */
    public function getList($table)
    {
'txtshippingtime' => 'shippingtime',
                    'txtArtikel' => 'name',
                    'txtzusatztxt' => 'additionaltext',
                    'metaTitle' => 'metaTitle',
                ];

                $attributes = Shopware()->Container()->get(CrudService::class)->getList('s_articles_attributes');
                foreach ($attributes as $attribute) {
                    if ($attribute->isIdentifier()) {
                        continue;
                    }
                    $columnName = $attribute->getColumnName();
                    $map[CrudServiceInterface::EXT_JS_PREFIX . $columnName] = $columnName;
                }
                break;
            case 'link':
                $map = ['linkname' => 'description'];
                break;
            case 'download':
                $map = ['downloadname' => 'description'];
                break;
        }
        if (empty($objectData)) {
            
$columns = $crudService->getList(
            $this->Request()->getParam('table')
        );

        $columns = array_filter($columnsfunction DConfigurationStruct $column) {
            return $column->isIdentifier() == false;
        });

        if ($this->Request()->has('columns')) {
            $whitelist = json_decode($this->Request()->getParam('columns', []), true);
            $columns = array_filter($columnsfunction DConfigurationStruct $column) use ($whitelist) {
                return \in_array($column->getColumnName()$whitelist);
            });
        }

        if (!$this->Request()->getParam('raw')) {
            $this->translateColumns($columns);
        }

        $this->View()->assign([
            'success' => true,
            'data' => array_values($columns),
            'total' => 1,
        ]);
$columns = [];
        for ($i = $offset$i <= $offset + $limit; ++$i) {
            if (!isset($data[$i])) {
                break;
            }
            $struct = $data[$i];
            if (!$struct->displayInBackend()) {
                continue;
            }
            $columns[] = [
                'column' => $struct->getColumnName(),
                'label' => $struct->getLabel() ?: $struct->getColumnName(),
                'type' => $struct->getColumnType(),
            ];
        }

        $this->View()->assign([
            'success' => true,
            'data' => $columns,
            'total' => \count($data),
        ]);
    }

    
Home | Imprint | This part of the site doesn't use cookies.