diff --git a/Classes/Controller/ProductController.php b/Classes/Controller/ProductController.php index 758b83b9..ccf06628 100644 --- a/Classes/Controller/ProductController.php +++ b/Classes/Controller/ProductController.php @@ -17,6 +17,8 @@ use Extcode\CartProducts\Domain\Repository\CategoryRepository; use Extcode\CartProducts\Domain\Repository\Product\ProductRepository; use Psr\Http\Message\ResponseInterface; +use TYPO3\CMS\Core\Cache\CacheDataCollector; +use TYPO3\CMS\Core\Cache\CacheTag; use TYPO3\CMS\Core\Pagination\SlidingWindowPagination; use TYPO3\CMS\Core\TypoScript\TypoScriptService; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -52,6 +54,8 @@ protected function initializeAction(): void ); $this->settings['addToCartByAjax'] = isset($this->settings['addToCartByAjax']) ? (int)$this->settings['addToCartByAjax'] : 0; + + $this->addPageCacheTags(['tx_cartproducts']); } /** @@ -168,6 +172,7 @@ public function listAction(int $currentPage = 1): ResponseInterface $this->assignCurrencyTranslationData(); + $this->addProductCacheTags($products); return $this->htmlResponse(); } @@ -183,6 +188,7 @@ public function showAction(?Product $product = null): ResponseInterface $this->assignCurrencyTranslationData(); + $this->addProductCacheTags($product instanceof Product ? [$product] : []); return $this->htmlResponse(); } @@ -196,6 +202,8 @@ public function showFormAction(?Product $product = null): ResponseInterface $this->view->assign('cartSettings', $this->cartConfiguration['settings']); $this->assignCurrencyTranslationData(); + + $this->addProductCacheTags($product instanceof Product ? [$product] : []); return $this->htmlResponse(); } @@ -208,6 +216,7 @@ public function teaserAction(): ResponseInterface $this->assignCurrencyTranslationData(); + $this->addProductCacheTags($products); return $this->htmlResponse(); } @@ -303,6 +312,32 @@ protected function assignCurrencyTranslationData() $this->view->assign('currencyTranslationData', $currencyTranslationData); } + /** + * @param iterable $products + */ + private function addProductCacheTags(iterable $products): void + { + $cacheTags = []; + foreach ($products as $product) { + $cacheTags[] = 'tx_cartproducts_product_' . $product->getUid(); + } + $this->addPageCacheTags($cacheTags); + } + + /** + * @param list $cacheTags + */ + private function addPageCacheTags(array $cacheTags): void + { + $cacheDataCollector = $this->request->getAttribute('frontend.cache.collector'); + if (!$cacheDataCollector instanceof CacheDataCollector) { + return; + } + foreach ($cacheTags as $cacheTag) { + $cacheDataCollector->addCacheTags(new CacheTag($cacheTag)); + } + } + protected function restoreSession(): void { $cart = $this->sessionHandler->restoreCart($this->cartConfiguration['settings']['cart']['pid']); diff --git a/Configuration/Services/EventListeners.php b/Configuration/Services/EventListeners.php index b9fc351d..f39d8b1b 100644 --- a/Configuration/Services/EventListeners.php +++ b/Configuration/Services/EventListeners.php @@ -104,7 +104,7 @@ [ 'event' => StockEvent::class, 'identifier' => 'cart-products--order--stock--flush-cache', - 'after' => 'cart-books--order--stock--handle-stock', + 'after' => 'cart-products--order--stock--handle-stock', ] ) ; diff --git a/Documentation/Changelog/7.2/Index.rst b/Documentation/Changelog/7.2/Index.rst index 72342737..717b8b84 100644 --- a/Documentation/Changelog/7.2/Index.rst +++ b/Documentation/Changelog/7.2/Index.rst @@ -9,12 +9,22 @@ :local: :depth: 1 +7.2.0 +----- + Features -^^^^^^^^ +~~~~~~~~ + +* :doc:`#274 - Add WatchlistItemHandler ` + +Bugfixes +~~~~~~~~ + +* Fix label path of related products in the product TCA (`#264 `__) +* Prepend extension name to upgrade wizard identifier (`#273 `__) .. toctree:: - :maxdepth: 1 - :titlesonly: + :hidden: :glob: - Feature-* + *-* diff --git a/Documentation/Changelog/7.3/Index.rst b/Documentation/Changelog/7.3/Index.rst new file mode 100644 index 00000000..9d2a2365 --- /dev/null +++ b/Documentation/Changelog/7.3/Index.rst @@ -0,0 +1,45 @@ +.. include:: ../../Includes.rst.txt + +7.3 Changes +=========== + +**Table of contents** + +.. contents:: + :local: + :depth: 1 + +7.3.3 +----- + +Tasks +~~~~~ + +* Check spelling with typos (`#311 `__) +* List the changes of each release in the changelog + +7.3.2 +----- + +Bugfixes +~~~~~~~~ + +* Use verdict() in IfBestSpecialPriceAvailableViewHelper for Fluid 4 (`#308 `__) + +7.3.1 +----- + +Bugfixes +~~~~~~~~ + +* Correct stock handling for backend variants (`#281 `__) +* Add missing value for area divider item (`#286 `__) +* Skip objects that are not a category in CategoryRepository (`#297 `__) + +7.3.0 +----- + +Compatibility +~~~~~~~~~~~~~ + +* PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 (was ~8.2.0 || ~8.3.0 || ~8.4.0) diff --git a/Documentation/Changelog/8.0/Breaking-287-PriceColumnsAsFixedPointNumbers.rst b/Documentation/Changelog/8.0/Breaking-287-PriceColumnsAsFixedPointNumbers.rst new file mode 100644 index 00000000..1078f7dc --- /dev/null +++ b/Documentation/Changelog/8.0/Breaking-287-PriceColumnsAsFixedPointNumbers.rst @@ -0,0 +1,39 @@ +.. include:: ../../Includes.rst.txt + +===================================================== +Breaking: #287 - Price columns as fixed-point numbers +===================================================== + +See `Pull Request 287 `__ + +Description +=========== + +The price columns in the database changed from ``double(11,2)`` to +``decimal(17,5)`` to store prices without rounding errors and with more +than two decimal places: + +* ``tx_cartproducts_domain_model_product_product``: ``price``, + ``price_measure``, ``base_price_measure``, ``service_attribute1``, + ``service_attribute2``, ``service_attribute3`` +* ``tx_cartproducts_domain_model_product_specialprice``: ``price`` +* ``tx_cartproducts_domain_model_product_quantitydiscount``: ``price`` +* ``tx_cartproducts_domain_model_product_bevariant``: ``price``, + ``price_measure`` + +Affected Installations +====================== + +All installations updating from cart_products 7.x. + +Own queries or extensions which read these columns directly get the values +as numeric strings instead of floats from the database. + +Migration +========= + +Update the database schema, e.g. with the database analyzer in the install +tool or with ``vendor/bin/typo3 extension:setup``. The existing prices are +kept. + +Cast the values of these columns in own queries, e.g. with ``(float)``. diff --git a/Documentation/Changelog/8.0/Breaking-287-RemoveAddCacheTagsFromProductController.rst b/Documentation/Changelog/8.0/Breaking-287-RemoveAddCacheTagsFromProductController.rst new file mode 100644 index 00000000..0d6418d3 --- /dev/null +++ b/Documentation/Changelog/8.0/Breaking-287-RemoveAddCacheTagsFromProductController.rst @@ -0,0 +1,32 @@ +.. include:: ../../Includes.rst.txt + +============================================================= +Breaking: #287 - Remove addCacheTags() from ProductController +============================================================= + +See `Pull Request 287 `__ + +Description +=========== + +The protected method +``\Extcode\CartProducts\Controller\ProductController::addCacheTags()`` was +removed, because it used ``$GLOBALS['TSFE']``, which no longer exists in +TYPO3 v14. + +Affected Installations +====================== + +All installations with an own controller extending the ``ProductController`` +which calls or overrides ``addCacheTags()``. + +Migration +========= + +Add cache tags with the cache data collector of the request: + +.. code-block:: php + + $this->request->getAttribute('frontend.cache.collector')->addCacheTags( + new \TYPO3\CMS\Core\Cache\CacheTag('tx_cartproducts_product_' . $product->getUid()) + ); diff --git a/Documentation/Changelog/8.0/Index.rst b/Documentation/Changelog/8.0/Index.rst index 799cb9ba..b201760e 100644 --- a/Documentation/Changelog/8.0/Index.rst +++ b/Documentation/Changelog/8.0/Index.rst @@ -8,3 +8,53 @@ .. contents:: :local: :depth: 1 + +8.0.2 +----- + +Bugfixes +~~~~~~~~ + +* Tag the page cache with the shown products again (`#313 `__) +* Flush the cache after handling the stock of products (`#313 `__) + +Tasks +~~~~~ + +* Check spelling with typos (`#310 `__) +* List the changes of each release in the changelog + +8.0.1 +----- + +Tasks +~~~~~ + +* Run tests and linters via Build/Scripts (`#295 `__, `#300 `__) + +8.0.0 +----- + +Compatibility +~~~~~~~~~~~~~ + +* TYPO3 ^14.3 (was ^13.4) +* extcode/cart ^12.0 (was ^11.0) + +Breaking +~~~~~~~~ + +* :doc:`#287 - Price columns as fixed-point numbers ` +* :doc:`#287 - Remove addCacheTags() from ProductController ` + +Bugfixes +~~~~~~~~ + +* Correct stock handling for backend variants (`#281 `__) +* Add missing value for area divider item (`#286 `__) + +.. toctree:: + :hidden: + :glob: + + *-* diff --git a/Documentation/Changelog/Index.rst b/Documentation/Changelog/Index.rst index ab8df6f6..ac5bed2a 100644 --- a/Documentation/Changelog/Index.rst +++ b/Documentation/Changelog/Index.rst @@ -11,6 +11,7 @@ ChangeLog :titlesonly: 8.0/Index + 7.3/Index 7.2/Index 7.1/Index 7.0/Index diff --git a/Documentation/guides.xml b/Documentation/guides.xml index f47f0e7d..81c46f0e 100644 --- a/Documentation/guides.xml +++ b/Documentation/guides.xml @@ -11,7 +11,7 @@ interlink-shortcode="extcode/cart-products" />