Przypina kategorię do obiektu z id
@param integer $attributeId id kategorii
972698
public function createAttributeRelation($attributeId)
    {
        //niepoprawna kategoria
        if (null === $attributeRecord = (new CmsAttributeQuery)
            ->findPk($attributeId)) {
            return;
        }
        //wyszukiwanie relacji
        $relationRecord = (new CmsAttributeRelationQuery)
            ->whereCmsAttributeId()->equals($attributeRecord->id)
            ->andFieldObject()->equals($this->_object)
            ->andFieldObjectId()->equals($this->_objectId)
            ->findFirst();
        //znaleziona relacja - nic do zrobienia
        if (null !== $relationRecord) {
            return;
        }
        //tworzenie relacji
        $newRelationRecord = new CmsAttributeRelationRecord;
        $newRelationRecord->cmsAttributeId = $attributeRecord->id;
        $newRelationRecord->object = $this->_object;
        $newRelationRecord->objectId = $this->_objectId;
        //zapis
        $newRelationRecord->save();
    }
613988
public function deleteAttributeRelationAction()
    {
        //wyszukiwanie rekordu relacji
        $record = (new \Cms\Orm\CmsAttributeRelationQuery)
            ->whereObjectId()->equals($this->id)
            ->findPk($this->relationId);
        //jeśli znaleziono rekord
        if ($record && $record->delete()) {
            //wyszukiwanie stron w zmienionym szablonie
            foreach ((new \Cms\Orm\CmsCategoryQuery)->whereCmsCategoryTypeId()
                ->equals($this->id)
                ->findPairs('id', 'id') as $categoryId) {
                //usuwanie wartości usuniętych atrybutów
                (new \Cms\Model\AttributeValueRelationModel('category', $categoryId))
                    ->deleteAttributeValueRelationsByAttributeId($record->cmsAttributeId);
            }
            $this->getMessenger()->addMessage('messenger.attribute.attributeRelation.deleted', true);
        }
    }
551552
private function _setId($pId)
    {
        $idField = ItemInterface::IDFIELD;

        if (! isset($this->_fields[$idField])
            or ! $this->_fields[$idField]) {
            $this->_fields[$idField] = $pId;
        }

        return $this;
    }
269726
public function initialize($attributes, $id = null)
    {
        if ($this->started) {
            return $this;
        }
        
        $this->id = $id ?: $this->id;
        $this->attributes = $attributes;
        $this->started = true;
        
        return $this;
    }
1284051
public function getValueByAttributeId($attributeId)
    {
        foreach ($this->values as $valueObject) {
            if ($valueObject->getAttribute()->getId() == $attributeId) {
                return $valueObject;
            }
        }

        return null;
    }
475478
public static function removeRelationsByContentClassAttributeId( $attributeId )
    {
        $id = (int)$attributeId;
        $db = eZDB::instance();
        $db->query( "DELETE FROM ezcontentobject_link WHERE contentclassattribute_id=$id" );
    }
707858
public function deleteAction($categoryId, $keywordId)
    {
        $keyword = $this->getKeywordRepository()->findById($keywordId);
        $category = $this->getCategoryRepository()->findCategoryById($categoryId);
        $this->getKeywordManager()->delete($keyword, $category);

        $this->getEntityManager()->flush();

        return $this->handleView($this->view());
    }
479532
public function addStyleId($styleId)
    {
        $styleId = (string)$styleId;
        if (!in_array($styleId, $this->styleIds)) {
            array_push($this->styleIds, $styleId);
        }
        return $this;
    }
528793
private function _createValueRelationByElement($attributeId, \Mmi\Form\Element\ElementAbstract $element)
    {
        //element ignorowany
        if ($element->getIgnore()) {
            return;
        }
        //checkboxy
        if ($element instanceof \Mmi\Form\Element\Checkbox) {
            return (new AttributeValueRelationModel($this->_saveToObject, $this->getRecord()->id))->createAttributeValueRelationByValue($attributeId, (integer) $element->isChecked());
        }
        //zwykła, skalarna wartość
        if (!is_array($element->getValue())) {
            return (new AttributeValueRelationModel($this->_saveToObject, $this->getRecord()->id))->createAttributeValueRelationByValue($attributeId, $element->getValue());
        }
        //tablica
        foreach ($element->getValue() as $value) {
            (new AttributeValueRelationModel($this->_saveToObject, $this->getRecord()->id))->createAttributeValueRelationByValue($attributeId, $value);
        }
    }
794043
public function attach($id, array $attributes = array(), $touch = true)
    {
        if ($id instanceof Model) $id = $id->getKey();

        $query = $this->newPivotStatement();

        $query->insert($this->createAttachRecords((array) $id, $attributes));

        if ($touch) $this->touchIfTouching();
    }
1204699
public function loadContentTypeDraftFieldDefinitionList($contentTypeId)
    {
        $contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);

        return new Values\FieldDefinitionList(
            $contentTypeDraft,
            $contentTypeDraft->getFieldDefinitions()
        );
    }
1006278
public function loadAttributesData(int $categoryId)
    {
        $binds = [':category_id' => $categoryId];

        $select = $this->getConnection()->select();
        $select->from($this->getMainTable())->where(sprintf("%s = :category_id", $this->getIdFieldName()));

        return $this->getConnection()->fetchAll($select, $binds);
    }
541154
public function countTotal($attributeId)
    {
        $qb = $this->getQueryBuilder()
            ->select('COUNT(av)');

        if (!is_null($attributeId)) {
            $qb->where('av.attribute = :attribute_id')
                ->setParameter('attribute_id', $attributeId);
        }

        return $qb->getQuery()->getSingleScalarResult();
    }
315128
public function actionSave($id = null, $languageId = null)
    {
        $category = (!empty($id)) ? Category::findOne($id) : new Category();
        $categoryTranslation = ((!empty($id)) ? CategoryTranslation::find()->where([
                'category_id' => $id,
                'language_id' => $languageId
            ])->one() : new CategoryTranslation()) ?? new CategoryTranslation();;

        return $this->render('save', [
            'viewName' => 'add-basic',
            'params' => [
                'languages' => Language::findAll(['active' => true]),
                'maxPosition' => Category::find()->where(['parent_id' => $category->parent_id])->max('position') ?? 1,
                'category' => $category,
                'categoryTranslation' => $categoryTranslation,
                'categories' => Category::find()->with('translations')->all(),
                'selectedLanguage' => Language::findOne($languageId),
            ]
        ]);
    }
299680
public function indexAction($attributeId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Attribute $attribute */
        $attribute = $em->getRepository('EcommerceBundle:Attribute')->find($attributeId);

        if (!$attribute) {
            throw $this->createNotFoundException('Unable to find Attribute entity.');
        }

        return array(
            'attribute'    => $attribute,
        );
    }
513540
public function removeVariantAttributeRelation($productId, $attributeId)
    {
        $variant = $this->retrieveProductById($productId);
        $attribute = $this->retrieveAttributeById($attributeId);

        if (!$variant->getVariantAttributes()->contains($attribute)) {
            throw new ProductException('Variant does not have relation to attribute');
        }

        $variant->removeVariantAttribute($attribute);

        return $variant;
    }
918706
public function showAction($attributeId, $id)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Attribute $attribute */
        $attribute = $em->getRepository('EcommerceBundle:Attribute')->find($attributeId);

        if (!$attribute) {
            throw $this->createNotFoundException('Unable to find Attribute entity.');
        }

        /** @var AttributeValue $entity */
        $entity = $em->getRepository('EcommerceBundle:AttributeValue')->find($id);

        if (!$entity) {
            throw $this->createNotFoundException('Unable to find AttributeValue entity.');
        }

        $deleteForm = $this->createDeleteForm($attributeId, $id);

        return array(
            'entity'      => $entity,
            'attribute'   => $attribute,
            'delete_form' => $deleteForm->createView(),
        );
    }