How do I get Magento 2 data to use in the template? - magento

I am starting in the Magento development world, and I'm creating a new theme.
On my theme, I have a block which displays business contact info, but I don't know how to get the data from the store.
I have to make a custom menu as well, but stop in the same problem: getting category data from the store.
I also wanted to know if there is any place where you can find more references on this data return issue, such as what available methods and classes are available, for example.

Where do you want to display the custom data ? In a product page or your custom module's separate page ?
If you want to use custom block in sidebar you can follow steps given here
https://aureatelabs.com/magento-2/how-to-add-a-static-block-in-a-sidebar-column-magento-2/.
Here are some ref you can use:
https://itectec.com/magento/magento-magento-2-get-custom-module-data-in-theme-phtml/
https://code.vky.co.in/display-custom-module-collection-data-frontend-magento-2/

Related

Managing contents in multilingual stores in Magento

This might be a basic question, I'm still relatively new to Magento. I have 2 store views in a magento project. 1 for English (default) and 1 for Japanese. While working with both store views, I noticed how if for example I switch to the Japanese store view, if I redirected to a different page or content on the store, the language goes back to English. How do I prevent the website from going back to the default language every time I change categories/catalogs?
That is all about Magento Admin setting. While creating Content Pages/Categories/products, there is a option that ask to choose Store View.
You can add content for Cateogries/Product/CMS Pages for each locale. If it is done then you'll be able to see your site content on the basis of current locale. Hence you need to go through Magento Admin first.
Hope it will work for you. Please let me know if any issue.
Managing contents in multilingual stores in Magento is easy.
Edit/Create Product/Category/Page/Static blocks according to need storeview and put content according to languages in that.
Now access pages by store code, if we are using that.
In some case we don't find the heading names according to languages so just enable inline translater from admin and do translation specific to store/website.
To run Magento store using urls we have both options index.php modifiction and using .htaccess using website and store codes.
On running Magento multisite , multistore. We generally face the common urls for media, js and other resources we should use symlink to increase SEO ranking and score.
Please feel free to contact.
Install your language package.
Create products, categories, pages, and static blocks on the basis of your selected language.
Sometimes translation does not work for few words. In those cases, Inline translation from admin will help you.
Managing content according to store view is very easy.
follow up below steps for managing content according to Store view.
Edit your product or category or your page and static block etc.
after that you can see store select left side in product and category and on page you can see feild below url in static block also. select your store view.
whater ever you want to change or edit please do according to you.
After that save it will apear only on your selected store.
Note: if you not edit any fild by store then it will show default store contents.

Adding Banner To Magento Product Page

Hi Everyone i am seek your expertise. I am working on a magento store and am wanting to add a banner to my product page like the image attached. This banner needs to be different on each product page so am wanting a way that i can either browse my computer for the image or add a url to the image location. I am thinking i need to create an attribute and then under Admin > Catalog > Manager Product > Images list i will be able to pull in the banner just like adding a new image product. Is this the correct way of doing it and if so, how can i specify on my template where the banner will be added (i.e at the top of the page). I have tryed to find some code where i can add so it knows that when i have this attribute to put it in that location. Any help would be much appreciated
Thanks
Ali
Sorry without the actual code there is not much help you will get. But this is an idea you can use:
Yes your thinking it correctly. Although a more elegant way to do this would be by adding an option in the image grid as (banner). This will allow you to use the power of existing image processing and handling systems in magento.
Once this is done; simply add the code in template file for product view page (I am not sure whether this is a enterprise or community version or you are using a theme. It's best to enable the developer debugger option to view the template file path).
In terms of adding this code this should be fairly simple. You just need to check any image has been flagged as "banner" or not. Then do some resize to fit in the page and it should work.
Hi you can simply create a one new attribute for a product using for banner image and you can use that attribute on product view page, and the banner will be display on product page according to each banner attribute value specify in the admin. This will be very simple in use.

Magento: adding product from frontend form

I have magento demo shop and for example i want registered user to be available to post a product from frontend? Can anyone hook me up with some code showing how to make it? Is it even possible in magento?
It's certainly possible. It actually shouldn't be all that difficult. You're going to create a module, programmatically create an order, and link this page from somewhere. You should be able to hack one together with the following resources:
Programmatically Creating Orders - Inchoo
Creating a Custom Module part 1-8
yes dear it is possible, you have to create a module for that and i think you give to link/tab in customer account page in front side.in account page you provide form of add new product.you have also provide all option like in magento back end. but some customization are required

Automatically generating Customer Attribute Form Fields

When you add customer attributes, Magento's admin dashboard for customer's automatically generates the relative form element for that new attribute.
Is there a way to do the same thing on the front end via a controller in a module?
nope, the frontend customer fields are hard coded, check out the phtml inside customer/form to see it.
What are you trying to achieve? Customer attributes are displayed on the form if "Show on frontend" is enabled. However those fields aren't saved from frontend by default. You need to extend fieldsets in your module for that, see config.xml in core Mage/Customer module
EDIT: actually that is true for enterprise edition, on CE you have to edit register.phtml (preferably by making a copy in your theme)

How do I create a Magento module or widget that will appear on the shopping cart page?

I’m having a lot of trouble understanding how to create a module that will add an extra button to the shopping cart page. I found lots of info on payment modules and stand-a-lone page modules, but nothing for this.
I simply need to add a button underneath the regular “Checkout” button that can post item data to another website. I’ve created a module but can’t get Magento to recognize it and display the button on that spot. Any help would be greatly appreciated, even just sending me to an existing tutorial that I haven’t been able to find. Thanks.
A custom module is probably overkill for this. Module means a very specific thing in Magento. It's a mechanism for inserting custom code into Magento's standard operations. All you want to do is add a button to the cart page. Editing the file at
./base/default/template/checkout/cart.phtml
(substitute your theme/site name if not using base or default)
is the place you'll want to start looking. Just find the phtml file that corresponds to the place you want to insert your custom HTML and have at it.

Resources