When setting up a new Hyvä project, you may see the error npm error Missing script: “build-prod” in the CLI while running the npm build command. The cause is that newer Hyvä versions replaced the old build-prod script. Hyvä 1.1.x…
Ignoring minimum cart quantity requirements on category pages (Magento 2)
Magento 2 supports minimum purchase quantities. This setting defines the minimum number of units that must be added to the cart. If you want the Add to Cart button on a Magento 2 category page (list.phtml) to ignore that minimum…
Deleting or renaming PageBuilder templates (Magento 2)
If you saved a PageBuilder template in Magento 2, there is no built-in option to rename it later. You can, however, edit the database directly. Look in the table pagebuilder_templatewhere your saved PageBuilder templates are stored. To rename a PageBuilder…
Forgotten Magento admin password?
No need to panic! If you have forgotten your Magento 2 admin password, you can create a new admin user from the command line (CLI). Go to your Magento 2 root directory and run:
|
1 |
php bin/magento admin:user:create --admin-user='nutzername' --admin-password='passwort123' --admin-email='nutzer@example.com' --admin-firstname='Ihr' --admin-lastname='Nutzer' |
After running the command (make…
CSS no longer loads (Magento 2)
Sometimes Magento 2 CSS files stop loading or are not displayed correctly. There are several possible causes, but running the following commands from the Magento 2 root directory will fix many of them:
|
1 2 3 4 |
rm -rf var/view_preprocessed/* rm -rf pub/static/* bin/magento setup:static-content:deploy de_DE en_US -f //(add additional languages if needed) bin/magento cache:clean |
Installing the Session Reaper patch APSB25-88 (Magento 2)
Adobe has released the critical APSB25-88 security patch (https://helpx.adobe.com/security/products/magento/apsb25-88.html). It addresses CVE-2025-54236, also known as “Session Reaper”. At the time of publication, dringend dazu geraten, to install the patch, all available Magento 2 versions were affected. The Session Reaper vulnerability…
Unable to enable or disable the cache in the admin (Magento 2)
Since Magento 2.2, individual cache types can no longer be enabled or disabled directly from the admin area when the store is in Production Mode. You have two ways to handle this: 1. Switch to developer mode:
|
1 |
php bin/magento deploy:mode:set developer |
Keep in…
Checking whether a product is in stock by product ID (Magento 2)
Use the following Magento 2 snippet to check stock availability by product ID:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public function __construct( \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry, ... ) { $this->stockRegistry = $stockRegistry; } $stockItem = $this->stockRegistry->getStockItem($productId); if ($stockItem->getIsInStock()) { echo "Product is in stock"; } else { echo "Out of stock"; } |
Et voilà!
Loading a configuration value from the core_config_data table (Magento 2)
You may need to retrieve a value from Magento 2′s core_config_data table. This table typically stores configuration settings entered in the admin area. Use the following code to read the required value:
|
1 2 3 4 5 6 7 8 9 |
public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, ... ) { $this->scopeConfig = $scopeConfig; } // Example: web/secure/base_url; any other path can be used $value = $this->scopeConfig->getValue('web/secure/base_url', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); echo $value; |
Reading a customer attribute (Magento 2)
Want to read a particular customer attribute in Magento 2? Use the following code to retrieve an attribute value for any customer by customer ID:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
public function __construct( \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, ... ) { $this->customerRepository = $customerRepository; } $customer = $this->customerRepository->getById($customerId); $customAttr = $customer->getCustomAttribute('what_ever'); if ($customAttr) { echo $customAttr->getValue(); } |