Magento2: How to create password protected cms page?

To make the cms pages, you have to use event/observer controller_action_predispatch_cms_page_view ON this event,fire an observer which will check current user is loggedin or not. If user is not loggedin this redirect to login page. events.xml define at app/code/{vendorname}/{ModuleName}/etc/frontend/ at code is like: <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Event/etc/events.xsd”> <event name=”controller_action_predispatch_cms_page_view”> <observer name=”add_login_checker” instance=”{VendorName}{Modulename}ObserverRestrictCmsPage” /> </event> </config> Observer file RestrictCmsPage.php located at app/code/{vendorname}/{ModuleName}/Observer/ Observer code like… Continue reading Magento2: How to create password protected cms page?

Adding low to high and High to low

Toolrbar.php file <?php namespace JJCustomproductshowPluginCatalogBlockProductProductList; class Toolbar extends MagentoCatalogBlockProductProductListToolbar { /** * Set collection to pager * * @param MagentoFrameworkDataCollection $collection * @return MagentoCatalogBlockProductProductListToolbar */ public function afterGetAvailableOrders(Toolbar $subject, $availableOrders) { // Remove ‘position’ from available orders if it exists if (isset($availableOrders[‘position’])) { unset($availableOrders[‘position’]); } return $availableOrders; } public function setCollection($collection) { $this->_collection = $collection;… Continue reading Adding low to high and High to low

How to Remove SORT BY “Price” Option in Magento 2?

Step 1: Create a di.xml file at the below path appcodeVendorExtensionetc <?xml version=”1.0″?>   <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”>       <type name=”MagentoCatalogModelConfig”>         <plugin name=”RemovePriceOption” type=”VendorExtensionPluginModelConfig”/>     </type>   </config> Step 2: After that, create Config.php in the following path VendorExtensionPluginModel And then add the code as follows <?php   namespace VendorExtensionPluginModel;   class Config {     public function afterGetAttributeUsedForSortByArray(MagentoCatalogModelConfig $catalogConfig, $options)     {         unset($options[‘price’]);         return $options;… Continue reading How to Remove SORT BY “Price” Option in Magento 2?

Postgres Sql in Payload

To use Payload with Postgres, install the package @payloadcms/db-postgres. It leverages Drizzle ORM and node-postgres to interact with a Postgres database that you provide. It automatically manages changes to your database for you in development mode, and exposes a full suite of migration controls for you to leverage in order to keep other database environments in sync with… Continue reading Postgres Sql in Payload

Authentication Operations in Payload

Login using REST API const res = await fetch(‘http://localhost:3000/api/[collection-slug]/login’, { 2 method: ‘POST’, 3 headers: { 4 ‘Content-Type’: ‘application/json’, 5 }, 6 body: JSON.stringify({ 7 email: ‘dev@payloadcms.com’, 8 password: ‘this-is-not-our-password…or-is-it?’, 9 }), 10}) 11 12const json = await res.json() 13 14// JSON will be equal to the following: 15/* 16{ 17 user: { 18 email:… Continue reading Authentication Operations in Payload

What’s the Difference Between MongoDB and PostgreSQL?

MongoDB MongoDB is a document database that stores data as key-value pairs in JSON documents. Each document can hold various types of data, including arrays, Booleans, numbers, strings, and nested documents. By using Binary JSON (BSON), MongoDB holds additional data types and processes data efficiently. With the data storage flexibility in MongoDB, you can store… Continue reading What’s the Difference Between MongoDB and PostgreSQL?

Payload Startup File for the Plesk Panel

Here is the startup file which can be used for the startup file import express from ‘express’ import payload from ‘payload’ import path from ‘path’ import nodemailerSendgrid from ‘nodemailer-sendgrid’ const sendGridAPIKey = process.env.SENDGRIDAPI_KEY require(‘dotenv’).config({ path: path.resolve(__dirname, ‘../.env’), }) const app = express() const PORT = process.env.PORT || 8000 // Redirect root to Admin panel app.get(‘/’,… Continue reading Payload Startup File for the Plesk Panel

Postgress Database Configration on Plesk

Firstly need to install a PostgreSQL on the server After that need to Configure the DB with the username and password from the local server If it is a server need to configure the db with SSD access from the server. Once the configuration is done the DB will be connected to the server and… Continue reading Postgress Database Configration on Plesk

Hosting of the Payload web application

in order to run the payload application on the server we need to configure the startup file with following code This code can be used for normal hosting platforms // Ensure that the ‘payload.config.js’ is in the correct directory const payloadConfig = require(‘./dist/payload/payload.config.js’); // Start the server const app = require(‘./dist/server.js’); // Check if server.js… Continue reading Hosting of the Payload web application

Plesk User permission

1. Set Ownership to Root Change the ownership of /var/log/plesk and its contents to root:root: bash Copy code sudo chown -R root:root /var/log/plesk 2. Set Permissions Set appropriate permissions for directories and files. Generally, directories should have 755 permissions and files should have 644. Set Permissions for Directories bash Copy code sudo find /var/log/plesk -type… Continue reading Plesk User permission