Gets the product ID stored in the field.

@param \eZ\Publish\SPI\Persistence\Content\VersionInfo $versionInfo

@return int product ID
420687
public function getFieldData(VersionInfo $versionInfo)
    {
        $query = $this->connection->createQueryBuilder();
        $query->select('product_id')
            ->from('ngsyliusproduct')
            ->where(
                $query->expr()->eq('contentobject_id', ':contentobject_id')
            )
            ->setParameter('contentobject_id', $versionInfo->contentInfo->id, Type::INTEGER);

        $statement = $query->execute();

        $rows = $statement->fetchAll(PDO::FETCH_ASSOC);

        return !empty($rows[0]['product_id']) ? (int) $rows[0]['product_id'] : null;
    }
1113362
protected function getIdProductAbstractByProductSku(string $productSku): int
    {
        $this->addProductToProductHeapBySku($productSku);

        return static::$productHeap[$productSku][static::PRODUCT_ABSTRACT_ID];
    }
957751
public function mapContent(VersionInfo $versionInfo, $languageCode)
    {
        $contentInfo = $versionInfo->contentInfo;

        return new Content(
            [
                'id' => $contentInfo->id,
                'mainLocationId' => $contentInfo->mainLocationId,
                'name' => $versionInfo->getName($languageCode),
                'languageCode' => $languageCode,
                'innerVersionInfo' => $versionInfo,
                'site' => $this->site,
                'domainObjectMapper' => $this,
                'repository' => $this->repository,
            ]
        );
    }
101676
public function load(VersionInfo $versionInfo): self
    {
        $languages = [];
        foreach ($versionInfo->languageCodes as $languageCode) {
            $languages[] = $this->languageService->loadLanguage($languageCode);
        }

        $this->data = array_map(
            function (Language $language) use ($versionInfo) {
                return $this->valueFactory->createLanguage($language, $versionInfo);
            },
            $languages
        );

        return $this;
    }
968287
public function getFieldData(VersionInfo $versionInfo, Field $field, array $context)
    {
        $product = null;

        $productId = $this->gateway->getFieldData($versionInfo);
        if (!empty($productId)) {
            $product = $this->productRepository->find($productId);
        }

        if ($product instanceof ProductInterface) {
            $product->setCurrentLocale(
                $this->localeConverter->convertToPOSIX($field->languageCode)
            );
        }

        $field->value->externalData = $product;
    }
494596
public function getManufacturerId()
    {
        if ($this->_sManufacturerId === null) {
            $this->_sManufacturerId = false;
            if (($manufacturer = $this->getActManufacturer())) {
                $this->_sManufacturerId = $manufacturer->getId();
            }
        }

        return $this->_sManufacturerId;
    }
575392
public function getNodePathString(VersionInfo $versionInfo)
    {
        $selectQuery = $this->connection->createQueryBuilder();
        $selectQuery
            ->select($this->connection->quoteIdentifier('path_identification_string'))
            ->from($this->connection->quoteIdentifier('ezcontentobject_tree'))
            ->where(
                $selectQuery->expr()->andX(
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_id'),
                        ':contentObjectId'
                    ),
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('contentobject_version'),
                        ':versionNo'
                    ),
                    $selectQuery->expr()->eq(
                        $this->connection->quoteIdentifier('node_id'),
                        $this->connection->quoteIdentifier('main_node_id')
                    )
                )
            )
            ->setParameter(':contentObjectId', $versionInfo->contentInfo->id, PDO::PARAM_INT)
            ->setParameter(':versionNo', $versionInfo->versionNo, PDO::PARAM_INT)
        ;

        $statement = $selectQuery->execute();

        return $statement->fetchColumn();
    }
346487
private static long getVersionId(String versionDir) {
        try {
            return Long.parseLong(versionDir.replace("version-", ""));
        } catch(NumberFormatException e) {
            logger.trace("Cannot parse version directory to obtain id " + versionDir);
            return -1;
        }
    }
428690
public function storeFieldData(VersionInfo $versionInfo, Field $field, array $context)
    {
        $this->gateway->deleteFieldData($versionInfo, [$field->id]);
        if (!empty($field->value->externalData)) {
            $externalData = $field->value->externalData;
            foreach ($externalData as $key => $tag) {
                if (!isset($tag['id'])) {
                    try {
                        $createdTag = $this->createTag($tag);
                        $field->value->externalData[$key]['id'] = $createdTag->id;
                    } catch (UnauthorizedException $e) {
                        // If users cannot create tags, just remove it from
                        // the list of tags to be created
                        unset($field->value->externalData[$key]);
                    }
                }
            }

            $this->gateway->storeFieldData($versionInfo, $field);
        }
    }
547702
public function getOneVersion($versionNumber, $con = null)
    {
        return ChildSkillVersionQuery::create()
            ->filterBySkill($this)
            ->filterByVersion($versionNumber)
            ->findOne($con);
    }
840920
public function deleteFieldData(VersionInfo $versionInfo, array $fieldIds, array $context)
    {
        $this->gateway->deleteFieldData($versionInfo, $fieldIds);

        return true;
    }
831973
public function contentVersion($contentId, $versionNo)
    {
        if ($this->allCleared === true || $this->isSwitchedOff()) {
            return;
        }

        // todo Once we can require 2.2.2+, simplify to just invalidate "content-{$contentId}-version-{$versionNo}"
        $this->cache->deleteItem("ez-content-version-info-${contentId}-${versionNo}");
        $this->cache->invalidateTags(["content-${contentId}-version-list", "content-{$contentId}-version-{$versionNo}"]);
    }
232795
protected function updateFieldData(VersionInfo $versionInfo, Field $field)
    {
        $connection = $this->getConnection();

        $updateQuery = $connection->createUpdateQuery();
        $updateQuery->update($connection->quoteTable('ezgmaplocation'))
            ->set(
                $connection->quoteColumn('latitude'),
                $updateQuery->bindValue($field->value->externalData['latitude'])
            )->set(
                $connection->quoteColumn('longitude'),
                $updateQuery->bindValue($field->value->externalData['longitude'])
            )->set(
                $connection->quoteColumn('address'),
                $updateQuery->bindValue($field->value->externalData['address'])
            )->where(
                $updateQuery->expr->lAnd(
                    $updateQuery->expr->eq(
                        $connection->quoteColumn('contentobject_attribute_id'),
                        $updateQuery->bindValue($field->id, null, \PDO::PARAM_INT)
                    ),
                    $updateQuery->expr->eq(
                        $connection->quoteColumn('contentobject_version'),
                        $updateQuery->bindValue($versionInfo->versionNo, null, \PDO::PARAM_INT)
                    )
                )
            );

        $updateQuery->prepare()->execute();
    }
81854
public function storeFieldData( VersionInfo $versionInfo, Field $field, array $context )
    {
        if ( empty( $field->value->externalData ) )
        {
            return;
        }

        /** @var LegacyStorage $gateway */
        $gateway = $this->getGateway( $context );

        $metas = $gateway->loadFieldData( $versionInfo, $field );
        if ($metas) {
            $gateway->deleteFieldData( $versionInfo, array($field->id) );
        }

        $gateway->storeFieldData( $versionInfo, $field );
    }
97273
private function loadVersionInfo($contentId): VersionInfo
    {
        return $this->repository->sudo(
            static function (Repository $repository) use ($contentId): VersionInfo {
                return $repository->getContentService()->loadVersionInfoById($contentId);
            }
        );
    }
619427
public function storeFieldData(VersionInfo $versionInfo, Field $field)
    {
        if ($field->value->data === null) {
            return;
        }

        $doc = new DOMDocument();
        if (!$doc->loadXML($field->value->data)) {
            return;
        }

        // Get all element tag types that contain url's or object_remote_id
        $urls = [];
        $remoteIds = [];
        $elements = [];
        foreach (['link', 'embed', 'embed-inline'] as $tagName) {
            $tags = $doc->getElementsByTagName($tagName);
            if ($tags->length === 0) {
                continue;
            }

            // First loop on $elements to populate $urls & $remoteIds
            /** @var $tag \DOMElement */
            foreach ($tags as $tag) {
                $url = null;
                if ($tag->hasAttribute('url')) {
                    $url = $tag->getAttribute('url');
                } elseif ($tag->hasAttribute('href')) {
                    $url = $tag->getAttribute('href');
                } elseif ($tag->hasAttribute('object_remote_id')) {
                    $remoteIds[$tag->getAttribute('object_remote_id')] = true;
                } else {
                    continue;
                }

                // Keep url unique if it has value
                if ($url) {
                    $urls[$url] = true;
                }

                $elements[] = $tag;
            }
        }
        unset($tags);

        // If we found some elements, fix them to point to internal ids
        if (!empty($elements)) {
            $linksIds = $this->getUrlIdMap(array_keys($urls));
            $objectRemoteIdMap = $this->getObjectId(array_keys($remoteIds));
            $urlLinkSet = [];

            // Now loop again to insert the right value in "url_id" attribute and fix "object_remote_id"
            /** @var $element \DOMElement */
            foreach ($elements as $element) {
                if ($element->hasAttribute('url')) {
                    $url = $element->getAttribute('url');
                    if (!$url) {
                        throw new NotFoundException('<link url=', $url);
                    }

                    // Insert url once if not already existing
                    if (!isset($linksIds[$url])) {
                        $linksIds[$url] = $this->insertUrl($url);
                    }
                    if (!isset($urlLinkSet[$url])) {
                        $this->linkUrl($linksIds[$url], $field->id, $versionInfo->versionNo);
                        $urlLinkSet[$url] = true;
                    }

                    $element->setAttribute('url_id', $linksIds[$url]);
                    $element->removeAttribute('url');
                } elseif ($element->hasAttribute('href')) {
                    $url = $element->getAttribute('href');
                    if (!$url) {
                        throw new NotFoundException('<link href=', $url);
                    }

                    // Insert url once if not already existing
                    if (!isset($linksIds[$url])) {
                        $linksIds[$url] = $this->insertUrl($url);
                    }
                    if (!isset($urlLinkSet[$url])) {
                        $this->linkUrl($linksIds[$url], $field->id, $versionInfo->versionNo);
                        $urlLinkSet[$url] = true;
                    }

                    $element->setAttribute('url_id', $linksIds[$url]);
                    $element->removeAttribute('href');
                } elseif ($element->hasAttribute('object_remote_id')) {
                    $objectRemoteId = $element->getAttribute('object_remote_id');
                    if (!isset($objectRemoteIdMap[$objectRemoteId])) {
                        throw new NotFoundException('object_remote_id', $objectRemoteId);
                    }

                    $element->setAttribute('object_id', $objectRemoteIdMap[$objectRemoteId]);
                    $element->removeAttribute('object_remote_id');
                }
            }

            // Store xml changes back to field
            $field->value->data = $doc->saveXML();
        }

        // Return true if some elements where changed
        return !empty($elements);
    }
1264117
public function setProductIdVersion($v)
    {
        if ($v !== null) {
            $v = (int) $v;
        }

        if ($this->product_id_version !== $v) {
            $this->product_id_version = $v;
            $this->modifiedColumns[DealerProductVersionTableMap::PRODUCT_ID_VERSION] = true;
        }


        return $this;
    }