updateProductTranslation example



    private function addProductTranslation(int $productId, int $languageId, array $data): void
    {
        $query = $this->connection->executeQuery(
            'SELECT id FROM s_articles_translations WHERE articleID = :articleId AND languageID = :languageId LIMIT 1',
            [':articleId' => $productId, ':languageId' => $languageId]
        );
        $exist = $query->fetch(PDO::FETCH_COLUMN);

        if ($exist) {
            $this->updateProductTranslation($exist$data);
        } else {
            $this->insertProductTranslation($productId$languageId$data);
        }
    }

    private function insertProductTranslation(int $productId, int $languageId, array $data): void
    {
        $data = array_merge($data['languageID' => $languageId, 'articleID' => $productId]);

        $query = $this->connection->createQueryBuilder();
        $query->insert('s_articles_translations');
        
Home | Imprint | This part of the site doesn't use cookies.