### Install Magento Module via Composer Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt Installs the Amasty Mage248Fix module using Composer, followed by enabling it and compiling dependencies through Magento CLI commands. This is the recommended installation method. ```bash # Navigate to Magento root directory and install the module composer require amasty/module-mage-248-fix -W # Enable the module and compile dependency injection php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento cache:flush ``` -------------------------------- ### Manually Install Magento Module and Dependencies Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt Provides steps for manual installation of the Amasty Mage248Fix module when Composer is not available. It includes placing module files and installing the LESS compiler dependency, followed by enabling the module via CLI. ```bash # Download and place module files in app/code/Amasty/Mage248Fix directory # Install required LESS compiler dependency composer require wikimedia/less.php:^5.3.1 # Enable the module php bin/magento setup:upgrade php bin/magento setup:di:compile php bin/magento cache:flush ``` -------------------------------- ### Module XML Configuration (etc/module.xml) Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt This XML file defines the module's name and its dependency on the Amasty_Base module. It follows the standard Magento 2 module declaration structure. ```xml ``` -------------------------------- ### Apply Magento 2.4.8 LESS Fix in Cloud Environment Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt Details the process for applying the responsive LESS fix in Magento Cloud environments with read-only filesystems. This involves manually copying the corrected LESS file before deployment and committing the changes. ```bash # Copy the fixed responsive.less file to lib/web/css/source/lib/ cp app/code/Amasty/Mage248Fix/lib/web/css/source/lib/_responsive.less \ lib/web/css/source/lib/_responsive.less # Commit and push the changes to your branch git add lib/web/css/source/lib/_responsive.less git commit -m "Apply Magento 2.4.8 responsive LESS fix" git push origin your-branch ``` -------------------------------- ### Composer Module Dependencies (composer.json) Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt This JSON file specifies the module's name, description, required PHP version, and its dependencies on other packages, including Amasty_Base, Magento Framework, and wikimedia/less.php. It also defines the package type and version. ```json { "name": "amasty/module-mage-248-fix", "description": "Fix several issues on Magento 2.4.8 version by Amasty", "require": { "php": ">=8.1", "amasty/base": ">=1.21.1", "magento/framework": "~103.0.8.0", "wikimedia/less.php": "^5.3.1" }, "type": "magento2-module", "version": "1.0.6" } ``` -------------------------------- ### Fix Theme Configuration Data Provider for Table Prefixes (PHP) Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt This PHP DataProvider class extends Magento's theme configuration data provider to correctly handle database table prefixes when querying the `core_config_data` table. It ensures that SQL queries function correctly on the admin theme change page, preventing errors by utilizing `resourceConnection->getTableName()` for proper prefix application. ```php resourceConnection = $resourceConnection; $this->storeManager = $storeManager; $this->filterBuilder = $filterBuilder; } public function getData(): array { // Apply filters for single store mode if ($this->storeManager->isSingleStoreMode()) { $singleStoreWebsite = $this->storeManager->getWebsite(); $this->addFilter( $this->filterBuilder->setField('store_website_id') ->setValue($singleStoreWebsite->getId()) ->create() ); } // Use resourceConnection->getTableName() for proper prefix handling $themeConfigData = $this->getCoreConfigData(); $data = parent::getData(); foreach ($data['items'] as &$item) { $item += ['default' => __('Global')]; // ... theme configuration logic } return $data; } private function getCoreConfigData(): array { $connection = $this->resourceConnection->getConnection(); // getTableName() properly applies configured table prefix $tableName = $this->resourceConnection->getTableName('core_config_data'); return $connection->fetchAll( $connection->select()->from($tableName) ->where('path = ?', 'design/theme/theme_id') ); } } // Configuration in etc/di.xml: // ``` -------------------------------- ### PHP Data Patch: Override Responsive LESS Library Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt This PHP data patch replaces Magento's core `_responsive.less` file with a corrected version. It ensures proper handling of the `min-width: (@screen__l)` media query in responsive styles. The patch includes revert functionality and creates a backup of the original file. ```php baseDir = $directoryList->getRoot(); $this->rootWrite = $writeInterface; $this->rootRead = $writeInterface; $this->rootWrite->open(['path' => $this->baseDir]); $this->rootRead->open(['path' => $this->baseDir]); } public function apply(): void { // 1. Backup original file to _responsive.less_bk $this->rootWrite->renameFile(self::LIB_PATH, self::LIB_PATH . '_bk'); // 2. Copy fixed version from module $moduleFilePath = __DIR__ . '/../../../../view/base/web/css/source/lib/_responsive.less'; $this->rootWrite->copyFile($moduleFilePath, self::LIB_PATH); // 3. Set proper file permissions $this->rootWrite->changePermissions(self::LIB_PATH, Deploy::DEFAULT_FILE_PERMISSIONS); } public function revert(): void { // Restores original file from backup if module file is still in place $backupPath = self::LIB_PATH . '_bk'; $currentPath = self::LIB_PATH; if ($this->rootRead->isExist($backupPath)) { if ($this->rootRead->readFile($currentPath) === $this->rootRead->readFile($backupPath)) { $this->rootWrite->delete($currentPath); $this->rootWrite->renameFile($backupPath, $currentPath); } else { $this->rootWrite->delete($backupPath); } } } public static function getDependencies(): array { return []; // No dependencies } } ``` -------------------------------- ### Custom Page Cache Identifier Implementation (PHP) Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt Implements a custom page cache identifier in PHP for Magento. This class, `IdentifierForRead`, ensures consistent cache key generation by prioritizing cookie vary strings over context vary strings, addressing issues with cache invalidation. ```php request->isSecure(), preg_replace($pattern, $replace, (string)$this->request->getUriString()), $this->request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING) ?: $this->context->getVaryString() ]; return sha1($this->serializer->serialize($data)); } } // Configuration in etc/frontend/di.xml: // // // // Amasty\Mage248Fix\Model\App\PageCache\IdentifierForRead // // // ``` -------------------------------- ### PHP Plugin: Keep Cache Valid on Store Switch Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt This PHP plugin for Magento's Page Cache ensures that the vary string from cookies is synchronized with the context vary string. It prevents cache invalidation issues when guests switch stores, ensuring proper cache behavior. ```php context->getVaryString(); $varyCookie = $this->request->get(HttpResponse::COOKIE_VARY_STRING); // When cookie vary is null but context vary exists, // set the request param to prevent cache key mismatch if ($varyCookie === null && $varyCookie !== $currentVary) { $this->request->setParam(HttpResponse::COOKIE_VARY_STRING, $currentVary); } } } // Configuration in etc/frontend/di.xml: // // // ``` -------------------------------- ### JavaScript Mixin: Fix Datepicker Positioning Source: https://context7.com/amastyltd/module-mage-248-fix/llms.txt This JavaScript mixin for Magento's calendar widget overrides the problematic `_overwriteFindPos` function. By leaving it empty, it prevents the datepicker popup from opening in incorrect positions after page scrolling, resolving issues with positioning calculations. ```javascript // File: view/base/web/js/calendar-fix-mixin.js // Automatically loaded via RequireJS configuration define([ 'jquery' ], function ($) { 'use strict'; return function (widget) { $.widget('mage.calendar', $.mage.calendar, { /** * Cancel overwriting of position calculation * Fixes GitHub issue #39831: Calendar popup opens in wrong position */ _overwriteFindPos: function () { // Intentionally empty - uses jQuery UI default positioning } }); return { dateRange: $.mage.dateRange, calendar: $.mage.calendar }; } }); // RequireJS configuration in view/base/requirejs-config.js: var config = { config: { mixins: { 'mage/calendar': { 'Amasty_Mage248Fix/js/calendar-fix-mixin': true } } } }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.