Categories
Magento Expert

Why Should You Try Magento Services?

What seemed like a competitive field once is now the essentiality in every business. Yes, we are talking about E-Commerce. Every second organization is trying to get itself registered on the digital platform and conduct business from there only. While we know the functions of e-commerce; we are somewhere short of knowing how to make it grow.

The Magento platform is indeed a boon for every business trying to achieve the attention of people worldwide. Combined with effective SEO services and branding, it does create a pool of opportunities for you. For those who are looking for Magento experts, you have come to the right place. But first let us tell you, why you need these services at the earliest.

Perks of Hiring Magento Experts 

Here is everything you need to know about what Magento experts do for you. Right from day one, your brand is plugged in to explore the new horizons it has never seen before.

  • Regular Monitoring: Entrepreneurs who have already taken a trial of e-commerce know very well how their sites respond, the errors that arise, the troubleshooting that is direly needed, and Magento services that should be monitoring these errors. And this is exactly what you get when you hire an expert to look after your website.
  • Optimization: Forget people logging into your website, what do you do when a certain website takes time to load? Yes, you do skip to some other site. If you do not wish for that to happen to your business site, you need an expert to optimize it. So, whenever one reaches for the products you offer, they wouldn’t have to wait to get what they are looking for.
  • Security: While the internet is a platform to increase the user-base of your products, it is also a place where several hackers come peeping into your site. Having your site hacked by any ordinary member of society is the last thing you’d want to happen to your business. Hence, by having Magento services, you give yourself a chance to protect your business.
  • Global Access: You never which part of the world your name travels in through digital platforms. Names you haven’t heard of and faces you haven’t imagined before come looking or your products. To maintain that scalability and offer access to each one out there, you need a good Magento service.

If you are thinking of hiring a magneto expert, do not think twice. Your business can reach new heights if it is put in the right managing hands.

Categories
Magento Expert

Ecommerce Development Trends that Every Magento Expert should Consider

The ever-changing dynamics of ecommerce development make it overwhelming for a business owner to keep up with the speed. That’s the reason why most businesses have at least one Magento expert by their side that can take care of their website and make it competitive in the modern world. And if you think that these trends will stop here, let us tell you that they won’t. You must be able to keep your Magento store ready all the time for your customers.

As a business owner, it might not be easy for you to ensure that your web store is up to date. You will need to hire a Magento expert who will take care of all your requirements while catering to your customers. Let’s take a look at the latest ecommerce development trends that every Magento developer tends to consider these days.

  • Personalization
    As per a new report, it has been found that customers are more attracted to a web store that can help them buy what they are looking for and not what it is selling. As more customers prefer offers and recommendations, no developer can overlook the importance of personalizing the web stores it is building. It also becomes a key to retaining customers as they will get to find products on the basis of their requirements and preferences. Personalized sales let business owners provide their customers with messages, discount codes, and sales announcements. As Magento comes with an exceptional customer segmentation feature, the expert developers can build dynamic segments for your customer base as per their purchase behavior.
  • Voice Search
    In the modern times, voice-enabled searches ease the shopping experience of each customer to a great extent. This clearly means that businesses must not shirk preparing their content searches because it is the future of all companies. Google also believes that textual content must be incorporated for voice search content so that the businesses can appear in the search graphs and snippets. It is the responsibility of the developer to classify products on the basis of voice activation to delve into voice search. It is important to take care of the conversation style while incorporating this feature because voice searches are meant to solve customer’s queries and it means that the developer will have to take care of the linguistic pattern using long-tail keywords mainly.
  • Chatbot
    Chatbots have been grabbing the eyeballs in modern times. They are generally coupled with artificial intelligence. When a customer’s query gets solved, there is an increased chance of him buying the product. On the basis of the customer’s shopping history and behavior, chatbots can also predict the future purchases of the customer. And it is not just text and voice that chatbots display but also tutorial videos, product images, web pages, blogs, and other relevant content. The chatbots are built in a way that they give customers the experience of talking live to a human being. These days, businesses are also incorporating the feature of placing orders through the messenger directly.

There is no denying the fact that when your ecommerce store is up to date, there is nothing that can stop you from enhancing your business. And because you are a specialist in your own field, you would need to get in touch with a Magento expert that understands your needs and can provide you with what you are looking for.

Categories
Magento Expert

Hire The Best Magento Experts With Towering Media For Your Business

ECommerce has been an ever-changing and updating platform to grow with. To make most of its features, one needs to have a remarkable place online. If you are also in such a pursuit, then never underestimate the power of a good platform and website developed over it. Your official site is like the digital business card that will let people recognize you and will enable your startup to get all the fame. Do you know which platform is all about the hype nowadays? Yes, it is none other than the Magento. To make the most of this open-source and well-functional platform, you need the assistance of a Magento ExpertBut, the main question that arises out of this need is where to find the best help for Magento development? Let us assist you- The top-notch development service providers are present at the Towering Media. Just reach out to them and your requirements will be fulfilled. But before you reach out be sure you know what exactly you need. Here are some exclusive tips for that- 

What to look for in the Magento Experts?

1. Consider your objective- How can you get your work done when you are unsure of your requirements? Seems, like one of the basic things to keep in the mind, right? Once you will be clear about your goal, then the time for defining your requirement in front of the professional is of utmost importance. When they will understand your objective, only then there is a possibility of them delivering it likewise to your company. This will also eliminate the rejection criteria and a lot of time will be saved. After all, you should keep in mind that you are getting a website developed on a complex platform like Magento. 

2. Define budget and skill set- Know what kind of services you are about to receive from the Magento Experts. You can check out their portfolio and see if their skills match your needs to find the most suitable match. When you will connect with a company like Towering Media, it becomes easy to have an uninterrupted showcase of previous expertise and testimonials. Their customer reviews can give you a realistic approach towards the features of the services you will get. Besides, their references and achievements can act as a great insight to finalize the hiring. Do you know the plus point of these professionals? They are the certified developers who can give world-class development and timely assistance to make your business stand out from the crowd. We hope, this is going to give you a clear picture of how your Magento based website looks like. 

The hiring of the Magento Experts is the first step to be taken by any startup which needs to have a great impact in the eCommerce world. So, contact Towering Media and get facilitated with the most favorable web development for organizational fame as well as excellence. 

Categories
Magento Expert

Find a Magento Expert to Grow Your E-Commerce Online Business

Towering Media is a leading firm for professional Magento service provider. We are well-renowned agency in the industry that provides a wide range of Magento services to their clients. Our Magento Expert team is highly skilled and talented in their skills. They have gained a lot of experience and learning from their years of working experience. We are specialized in various Magento services that are offered to our clients.

We provide reliable and unique e-commerce website solutions to our clients. Our experts are very proficient in their work and keep on experimenting with their innovative ideas and technique to bring out something unique in every project. This versatile style of working is the main reason we attract clients easily.

We have been in this industry since 2008. With each passing year, we have cherished the success of our growth. This successful journey belongs to our hard-working and innovative Magento Experts whose only motive is to provide profitable business solutions to their clients. We are recognized as a well renowned and a leading Digital Agency that provides the best and high quality of e-commerce business solutions. Whether it is about planning, designing, development, or deployment we provide all the services according to client requirements at affordable prices.

We serve services according to our client requirements. If you want your project from scratch we can assist you in that. If you want customized integration we are available for that also. Our strategists keep our clients in coordination at every step of the project i.e. From Planning, designing, development, testing, and deployment to maintenance. It helps them to know what services and implementation are being done on their project. Moreover, it helps them to trust easily and builds a strong client- business relationship.

Have a plan to grow your business? Discuss it with us. We can bring and fulfill your dreams into reality. Our experts put all their efforts, knowledge, and abundance of experience to make a project a huge success. We value our clients and put them on the highest priority. Understanding their vision and implementing it into reality is what matters to us.

Categories
Magento Expert

Magento Experts- Your Personalized eCommerce Website Developers

Built on open-source technology, Magento is all about the hype in the duration in the world of development and eCommerce. We cannot find a more flexible, content, and functionality embedded platform other than this dope place for Magento Experts. This is undoubtedly a powerful, and amazing management tool for new business as well as for the fully established venture. Top brands like Olympus, Nike, Lenovo, Ford, and Samsung use this exceptional platform for their websites. In fact, there are numerous businesses adopting it day by day. Do you wish to be part of this vast community and take your startup to the skyrocketing heights? Well, all you need is to contact a great company near to you which can develop your website over Magento. Let us tell you more about this interesting platform first. 

Magento platform must be your preference for business success

1. Awestruck Aesthetics – A website is the representation of any business that tells the tale of your organization’s caliber even before you give any presentation. Trust us, your various potential clients will judge your entity with the impression of your site. Ask a Magento Experthow great design, easy to use, and overall impressive website can impress your client in no time. No wonder you require Magento as it can give you a beautiful, flexible, and high-performance website with exceptional community support like no other platform. This is the ultimate reason why Magento gained so much fame in a few years, unlike other platforms that are still thriving for attention. 

2. Customizable – Nothing can beat the power of customization to win the trust of users and make them your loyal customer. That personalized feel is enough to keep them intrigued with your top-notch products and services. Eventually, leading to more and more conversions in favor of your company. Think of the themes that are just depicting your mission, vision, and goals! It is already so much interesting and you can get it all with Magento. How cool is that? 

We are sure you are so amazed by this fantastic platform and seeking the best Magento Experts, to begin with, your official website. Do not look here and there, just reach out for the Towering Media and give all your aspirations in their hands regarding your business site. Good look for upcoming online ventures. 

Categories
Magento Expert

Top Questions to Ask a Magento Expert Before Initiating Your Website

The last decade was a period of immense growth for eCommerce startups. A lot of new entrepreneurs are trying their luck online with the best possible platform. Needless to say what they have been relying on- Magento is so popular for web development in the duration. The idea was to put Magento at work to sell products online and set a stand out example. There are a lot of benefits that Magento gives business owners and take their business to touch new peaks of success. Multiple website management, third-party integration, secure payment options, Magento community support, SEO- friendly platform, and overall commendable performance are some of the specialties of Magento. To avail of all these advantages, you need a Magento expert. Well, if you are in a dilemma then please fret not as our exclusive guide will help you find a reliable professional to handle your Magento based website.

Benefits of Magento expert for your business:

  • Technical know-how is one of the main advantages of hiring a professional for Magento development. They can do coding, and design, with effective planning for the success of your business.
  • While your expert developer is doing every website-related task, you can save your time and concentrate on other vital accomplishments.
  • This website with Magento can be the best representation of your business with the choicest features, customizations, and out of the box aesthetics.
  • You can save a lot of money by getting your official business card or your website over Magento and also avail the benefit of a minimized downtime.
  • Outstanding site performance with reduced loading time and well-optimized operations impress users in no time. This is how they come back whenever they get an amazing experience during the first time.

Now, you are sure what facilitations can a Magento expert provides you. So, next, you must know what kind of developer you require- Front end Magento developer, Full-stack Magento developer, or Back end Magento developer. Select what you require and get going.

Yes, all these features and specifications are available at the Towering Media and their Magento expertsAll you need is to reach out to them via their official website or directly to any of their executives and begin with your powerful business journey like a pro.

Categories
Magento Expert

Hiring the Magento Experts for Migrating to Updated Version

You may find several resources claiming that Magento is the far best platform for developing an eCommerce platform. But have you heard about Magento 2 migration yet?

If not, you’re seriously missing some of the advanced features and unmatched performance of Magento that can thrive your business success.

Yes, Magento 2 is designed in a way to help startups, huge businesses, and Magento Experts to leverage the best functionalities for enhanced user and development experience.

As a business owner, you can eventually get benefitted in endless ways if you switch to the upgraded version of the most reliable eCommerce platform.

Here’s how a Magento enthusiast can help you in getting the best out of your eCommerce business in the future.

Hassle-Free Migration

One of the biggest reasons to choose a Magento developer for migrating to an updated version of the platform is the fact that one cannot perform the task without expertise.

The entire process requires a lot of time as well as needs adequate knowledge of handling the products, plugins, and overall security in a way that there are least chances of data loss.

Quick Deployment & Data Security

Migrating to the updated version requires a lot of time, which is perhaps the reason you must consider an expert to shun any chance of risking your precious data related to the product, clients’ information, and other essential details.

Installing Features & Plugins

Installing crucial features and previously installed plugins is quite a challenging task in Magento 2 and must be carried out by the experts with adequate experience. One should seek professional help if they are planning to perform the migration process smoothly.

Apart from this, the experts ensure that the plugins installed on your platform aren’t affecting the overall performance of the website. This depicts the importance of Magento Experts in enhancing the overall migration experience, which you can expect while you plan to manage things without professional help.

Testing and Ensuring Everything is Working Flawlessly

Testing is a crucial part of the migration process, which shouldn’t be ignored. Once the changes and data migration process is completed, the developer must thoroughly test the website for any flaws and errors.

Making detailed reports regarding any issues and its resolution must be the biggest priority of the developer. Once the entire website is tested, it is the right time to go live to scale business growth.

These aspects showcase the need for professional help while one decides to migrate from the current Magento 1 version to Magento 2.

Categories
magento 2 Magento Developer Magento Expert

How to create Bundle product in Magento2

To create a bundle product Magento Experts  usually follow these steps.

Step 1:  Select the required Product Type.

Step 2: Choose the Attribute Set for the bundle product.

Step 3: Complete the Required Attributes.

Step 4: Complete other remaining details of the Product.

Step 5: Add the Bundle Items.

Step 6: Generate the Product.

Step 7: View the Product in stores.

Step 1: Choose the required Product Type

On the Admin menu, click on Products > Catalog.
From product grid in the top-right corner of the Add Product menu, select the option Bundle Product.

Step 2: Choose the Attribute Set for the bundle product

Select an attribute set which is to be used as a template for the product.

In the Search box, type the name of the attribute set and from the list, choose the attribute set that you want to use.

 

Step 3: Complete the Required attrinbutes
  • Under the Product Detail  give Product Name.
  • You can either use the default SKU or can use any other value.Hence you can fix the type of value to “Dynamic” or “Fixed”.
  • In order to fix the Product Price you can either select “Dynamic” and leave Price field blank in case you want to change the price according to the selected options. OR just choose “Fixed”and enter the price in the given field in case you want to set price for the bundle.
  • As the product is yet not ready to be published so tick the “Off”checkbox for Product Online » Save

 Step 4: Complete other remaining details of the Product.

You can add an image of the product by doing either one of the two following ways:

Drag and Drop the image to the Camera option under Image and Video Box.OR

Clicking on the Camera Tile of Image and Video Box and browse the image you want to select from the folder of your desktop.Since the Product Group is made through individual objects the quantity will be unavailable.Shipping weight of the product can be set with the below given options(you can choose any one of them):

  • If the price is be decided according to the  option selected then choose “Dynamic” and leave the weight field blank.
  • Or,if you want to set a product weight then opt for “Fixed” and enter the correct weight in the weight field.

In order to assign a product to a category you either:

Type and find from Search box ,or

From the category tree select Show List icon then click on any available category you want to assign to the product,or

Create new category by typing the Category Name and assigning it to the Parent Category, then click on Create Category.

you can give brief description on product and Submit.You can also use the WYSIWYG Editor for additional control.


Step 5: Add the Bundle Items.

 

Set Ship Bundle Items from Bundle Item Section then click on Create New Option now enter Option Title.Set Input Type to Drop-down, Radio buttons, Checkbox, or Multiple Select ,mark the Required checkbox it will make the field required.Select Add Product to Option and carefully check the checkbox of each product which you want to include in the option.

  • If u find the needed product from the list you can use list filters and pagination control.You can make one of the item to become the Default Selection.Under Default Quantity Column enter the quantity of the each bundle item.
  • By clearing Use Defined checkbox set the fixed quantity of each item.Remember if u leave it default the quantity can be changed.
  • Repeat for other items .

click Delete option to remove any item.Finally click Save.


Step 6: generate the Product.

Switch “ON” Product Online option if you are ready to publish the product .

Now click Save & Close


Step 7: View the Product in Your Store

Admin Menu » Customer View


In case if you still face any issue to create a bundle product, please contact our Magento Developer.

Categories
magento 2 Magento Developer Magento Expert Uncategorized

Javascript Init Scripts for Magento2

Our Magento experts  are  going to describe the various systems Magento 2 has for kicking off execution of javascript code without an embedded <script type=”text/javascript”> tag.

Javascript Init Methods

First thing is , they are providing a standard technique to discourage directly embedding javascript into a page.

Secondly  they provide a way to invoke a stand alone RequireJS module (defined with define) as a program.

Third, they are providing a way to pass that program a server side generated JSON object.

Lastly, they are  providing a way to tell that program which (if any) DOM nodes it should operate on.

Keep these four steps in mind.

Set up a Module

We’re going to use pestle to create a module named Toweringmedia_JavascriptInitTutorial with a single URL endpoint by running the following three commands

$ pestle.phar generate_module Toweringmedia_JavascriptInitTutorial 0.0.1

$ pestle.phar generate_route Toweringmedia_JavascriptInitTutorial frontend Toweringmedia_javascriptinittutorial

$ pestle.phar generate_view Toweringmedia_JavascriptInitTutorial frontend toweringmedia_javascriptinittutorial_index_index Main content.phtml 1column

$ php bin/magento module:enable Toweringmedia_JavascriptInitTutorial

$ php bin/magento setup:upgrade

Now  run the above, you will be able to access the following URL in your browser.

http://magento.example.com/toweringmedia_javascriptinittutorial/

and you see the rendered app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml template.

Set up a RequireJS Module

Now we are doing a quick review and make a RequireJS module. First, create the following file

//File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/web/example.js
define([], function(){
alert(“A simple RequireJS module”);
return {};
});

Due to the module’s location on the file system, and the way Magento loads javascript files, this module’s name/identifier is Toweringmedia_JavascriptInitTutorial/example

Next, change this contents of content.phtml so they can match the following.

#File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml
<script type=”text/javascript”>
requirejs([‘Toweringmedia_JavascriptInitTutorial/example’],function(example){
alert(“Loaded”);
console.log(example);
});
</script>

Now we makes a RequireJS program with a single module dependency. The dependency is our just makes a  module (Toweringmedia_JavascriptInitTutorial/example). Load the

http://magento.example.com/toweringmedia_javascriptinittutorial/
URL in your system, and you should see the wary.

If any of the above was foreign to you, you can want to review our Magento 2 and RequireJS article.

X-Magento-Init

#File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml
<div id=”one” class=”foo”>
Hello World
</div>
<div id=”two” class=”foo”>
Goodbye World
</div>

<script type=”text/x-magento-init”>
{
“*”: {
Toweringmedia_JavascriptInitTutorial/example”:{}
}
}
</script>
Give your page a reload with the above, and you will see the wary from our example.js file.

If you’ve never seen this syntax before, it’s look like a little kinky. Let’s take it segmented by pieces.

First is the <script/> tag

#File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml
<script type=”text/x-magento-init”>
//…
</script>
The tag is not a javascript tag. Notice the type=”text/x-magento-init” attribute. When the browser doesn’t identify the value in a script’s type tag, it will skip the contents of that tag. Magento (similar to other modern javascript frameworks) uses this behavior to its advantage. While it’s beyond the scope of this tutorial, there’s Magento javascript code running that will scan for text/x-magento-init script tags. If you want to pursue this yourself, this Stack Exchange question and answer is a good position to start.

The another part of the x-magento-init code shred we can talk about instantly is the following object

#File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml
{
Toweringmedia_JavascriptInitTutorial/example”:{}
}
Magento will looks at the principal of this object, and include it (the key) as a RequireJS module. That’s what loading our example.js script.

You may also be thinking why the whole thing is a part of other object with a * as a main content.

#File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml
{
“*”: {/*…*/}
}
Before we can talk about that, we’ll need to discussion about javascript components.

Magento Javascript Components

The above example runs our RequireJS module as a program. This works, and Magento itself often uses the x-magento-init procedure to invoke a RequireJS module as a program. However, the strength of x-magento-init is the ability to makes a Magento Javascript Component.

Magento Javascript Components are RequireJS modules that return a function. Magento’s system code will call this function in a particular mode that disclose more functionality.

If that didn’t make sense, try changing your RequireJS module so it matches the following.

//File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/web/example.js
define([], function () {
var mageJsComponent = function()
{
alert(“A simple magento component.”);
};

return mageJsComponent;
});
Here we’ve defined a function and imposed it to a variable named mageJsComponent. Then, we return it.

If you refresh the page with the above in place, you will see A Simple Magento Component in an alert box.

It may seem silly — what’s the point of returning a function if all Magento does is call it? You’d be right, but that’s because we left something out. Try alternative our phtml template so it matches the following

#File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml
<div id=”one” class=”foo”>
Hello World
</div>
<div id=”two” class=”foo”>
Goodbye World
</div>

<script type=”text/x-magento-init”>
{
“*”: {
Toweringmedia_JavascriptInitTutorial/example”:{“config”:”value”}
}
}
</script>
and changing our RequireJS module so its view like

//File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/web/example.js
define([], function () {
var mageJsComponent = function(config)
{
alert(“Look in your browser’s console”);
console.log(config);
//alert(config);
};

return mageJsComponent;
});
If you refresh the page, you will see the changed alert message. If you look into the browser’s javascript console, you can also see the following

> Object {config:”value”}
When we make a Magento Javascript Component, Magento calls the returned function and includes the object from text/x-magento-init.

Toweringmedia_JavascriptInitTutorial/example”:{“config”:”value”}
It is why the RequireJS module name is a key — the value of this object is the object we want to pass to our component.

However, in a real module, we’d be yield that JSON with PHP.  This system allows us to render the JSON in our phtml template, and then have that passed to Javascript code. This helps skipped the problem of produces Javascript directly with PHP, which can lead to too much Garbage code, and build it easy to accidentally slip in an error or security problem.

Before we complete with x-magento-init, there’s one final feature to discuss. You’ll retain in mind that we said that x-magento-init

provides a mode to pass that program a server side created JSON object.

prescribe a mode to provide that program with the DOM nodes it should operate on.

We’ve covered how to pass in server side generated JSON — but what about the DOM nodes?

Change the RequireJS module so it looks like this

//File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/web/example.js
define([], function () {
var mageJsComponent = function(config, node)
{
console.log(config);
console.log(node);
//alert(config);
};

return mageJsComponent;
});
What we’ve completed here is add a another parameter to our mageJsComponent function. This another parameter will be the DOM node we want our program to operate on. if you refresh the page with the above in position, you’ll see the following in your console.

> Object {config:”value”}
> false
Magento did pass in a value for node — but that value was wrong. What gives?

Its necessary that, Change your phtml template so it matches the following.

#File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml

<div id=”one” class=”foo”>Hello World</div>
<div id=”two” class=”foo”>
Goodbye World
</div>

<script type=”text/x-magento-init”>
{
“#one”: {
Toweringmedia_JavascriptInitTutorial/example”:{“config”:”value”}
}
}
</script>
Here, we’ve changed the * to a #one. The * we used earlier is actually a particular incident, for programs that don’t need to operate on DOM nodes. The principal for this object is actually a CSS/jQuery style selector that tells Magento which DOM nodes the program in Toweringmedia_JavascriptInitTutorial/example should operate on. If we refresh our page with the above in position, we’ll see the following in your console

> Object {config: “value”}
> <div id=”one” class=”foo”>Hello World</div>
You’re not limited to IDs — you can uses CSS class identifiers. Change it to

#File: app/code/Toweringmedia/JavascriptInitTutorial/view/frontend/templates/content.phtml
“.foo”: {
Toweringmedia_JavascriptInitTutorial/example”:{“config”:”value”}
}
and you’ll see the console below.

> Object {“config”:”value”}
> <div id=”one” class=”foo”>Hello World</div>
> Object {“config”:”value”}
> <div id=”two” class=”foo”>Goodbye World</div>
By constructing this sort of system, Magento is encouraging developers to skip hard coding their DOM nodes into their RequireJS modules. The x-magento-init means there’s a system level path forward for building Javascript modules that confide on server side rendered JSON, and operate on any arbitrary DOM node. It’s evermore possible for Magento module developers to performance their own systems for this sort of functionality, but Magento 2 provides a standard, built in way to achieve this.

Data-mage-init Attribute

In addition to <script type=”text/x-magento-init”>, there’s other  mode to invoke analogous functionality on a specific DOM node, and that’s with the data-mage-init attribute. Try replacing the existing phtml template with the following

<div data-mage-init='{“Toweringmedia_JavascriptInitTutorial/example”: {“another”:”example”}}’>A single div</div>
Refresh the page with the above in position, you will see the  javascript console.

> Object {another: “example”}
> <div>A single div</div>
Here, we’ve added a data-mage-init attribute to a perticular div. This attribute’s value is a JSON object. Similar to x-magento-init, this object’s principal is the RequireJS module we want to invoke as a program or Magento Javascript Component, and the merit is a nested JSON object to pass into our Magento Javascript Component function as the config parameter.

On a pedantic note — you’ll see what we used single quotes with our attribute

<div data-mage-init=’…’>A single div</div>
The value of the data-mage-init attribute is parsed by a strict JSON parser, which means the JSON object’s quotes must be double quote — which means we can’t use double quotes for our attribute. While this is technically very well in HTML5, for web programmers of a particular age it brings back some poor Microsoft Frontpage memories.

Wrap Up

Whether you finishing by using the <script type=”text/x-magento-init”> component or a data-mage-init attribute in a specific node, both these techniques gives a standard, system unified mode of proposing Javascript entry points onto your page. Many of Magento’s front end and back end UI features rely on this syntax, so even if you personally throw away them, understanding how these systems work is significant part of being a Magento 2 developer.

 

Categories
magento 2 Magento Developer Magento Expert

Rewrite controller in Magento 2

Create a custom module for magento2 and then create a di.xml file into the directory [Name Space]/[Your Module]/etc/di.xml

Add the following code

<?xml version=”1.0″?>

<config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd”>

<preference for=”Magento\Cms\Controller\Index\Index” type=”[Name Space]\[Your Module]\Controller\Cms\Index” />

</config>

Now defining an overriding controller class

Create Index.php in app/code/[Name Space]/[Your Module]/Controller/Index

<?php

namespace [Name Space]\[Your Module]\Controller\Index;

class Index extends \Magento\Cms\Controller\Index\Index

{

public function execute($coreRoute = null)

{

// todo

}

}

If you facing any issue with please consult with our magento experts