Now we have to create the styling file. All the css and js files must be created under view/{areacode}/web folder.
All configuration is done in the requirejs-config.js file. It has a single root object config which contains the configuration options described below.
When we use the getUrl function, we pass an array as the second parameter. This array contains key-value pairs, like ['id' => $post->getEntityId()]. These key-value pairs are added to the URL as parameters when generating the link. For example, ?id=123 would be added to the URL if ['id' => 123] was passed in the array.
$escaper->escapeUrl() is used to escape the URL generated by $block->getUrl() method. It ensures that the URL is properly encoded and safe to use within an HTML attribute.
$block->getUrl('blog/manage/edit', ['id'=>$escaper->escapeHtml($blog->getId())]) is used to generate the URL for the "Edit" action of the "Blog" module. It constructs the URL based on the provided route and parameters. In this case, it generates the URL for editing a specific blog post by passing the blog post ID as a parameter.
Rich Snippets take a normal snippet… and add to it.
Here’s an example of a Rich Snippet:
Inspect the Source Code: Right-click on the webpage where the schema markup is being displayed and select "View Page Source" or "Inspect" (depending on your browser). Look for the <script> tags containing JSON-LD data, which represents the structured data. Each <script> tag usually corresponds to a specific schema markup.
Identify the Content: Within the JSON-LD script, look for the content that describes the structured data. Depending on the schema type (e.g., Product, Organization,
use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\RequestInterface; use Magento\Framework\View\Result\Page; use Magento\Framework\View\Result\PageFactory;
/** * Class Index */ class Index implements HttpGetActionInterface
Declarative Schema is a feature introduced in Magento 2.3 that provides a new way to define database schema changes using XML files. Traditionally, database schema changes in Magento were defined using InstallSchema and UpgradeSchema PHP scripts. However, with Declarative Schema, you can define the database schema changes in XML format, making it more readable and easier to manage.
In Declarative Schema, you describe the structure of your database tables, columns, indexes, and foreign keys in XML files located in the module's etc/db_schema.xml directory. These XML files provide a clear and concise representation of the database schema changes, making it easier to understand and maintain.
Declarative Schema also provides benefits such as improved performance during setup and upgrades, better compatibility with version control systems, and easier collaboration among developers working on database-related tasks.
Overall, Declarative Schema simplifies the process of managing database schema
The model is like a way of communcation for a single row in a table. It hides the complexity of how it interacts with the database, making it easier to work with the data.
The model class will extend \Magento\Framework\Model\AbstractModel and implements \Magento\Framework\DataObject\IdentityInterface. The IdentityInterface will force the Model class to define the getIdentities() method which will return a unique id for each model.
Resource Model
So we can create Resource model folder and Blog.php under it.
Collection
We understand that in the context of database tables, a model represents an individual row, while a collection encompasses all the rows within that table. You can envision the collection as a group of models or equivalently, as executing a "Select * From Table table_name" query.
When we need to work with multiple rows, such as retrieving all records, applying filters using "where" or "like" clauses,
I will make it very simple sweet and short. No long boring text. Just to the point.
Lets start!
Magento 2 only need two files to register and initialize a module.
registration.php: This file is located in the root directory of your module (app/code/Anees/Training/registration.php). It uses a Magento function to register the module with the framework.
etc/module.xml: This file is located within the etc folder of your module (app/code/Anees/Training/etc/module.xml). It defines the module's name, setup version, and any dependencies it might have.
After adding above two files run command bin/magento module:enable Anees_Training
Remember this is just a start. Magic will happen later when you go to advance level.
So first you have to check where you are getting collection. Most of time its coming from block and this blog also share how to do it when collection is coming from block.
Now go to your block file and add a _prepareLayout() function. This function render the layout of page as its visible from its name like we can set page title and other things also this function runs automatically.
See below function.
protected function _prepareLayout() { parent::_prepareLayout(); $this->pageConfig->getTitle()->set(__('My Reward History'));
// Assuming $macAddress is available, get records for the given MAC address $blockss_c = $this->getLayout()->createBlock('\Motoris\Vehiclelookup\Block\Cookie'); $macAddress = $blockss_c->get('customer_veh');