Add additional fields in the payment form in Magento 2 - magento

I have tried to add additional fields in the payment form in Magento 2, but I have not succeeded. I have reviewed several manuals on this, but I can't find a definitive one.
What I want is to add 2 fields, in the first one that allows choosing the type of document as dropdown and the second field is displayed to complete the information with the chosen document number.
If anyone has managed to implement this type of requirement, I would greatly appreciate your help.
I have tried to add additional fields in the payment form in Magento 2, but I have not succeeded. I have reviewed several manuals on this, but I can't find a definitive one.

Related

What are the options for marking/flaging documents in Elasticsearch?

Let's assume I have a front-end app for a blog and I stored the blog posts in an Elasticsearch instance (this is a hypothetical example).
I want multiple users to be able to mark some blog posts as favorite and the super users to be able to flag blog posts. For marking as favorite, only the user that did the marking is able to see it as marked. For flagging, if one user flags it, all the other users sees it as flagged.
I was thinking about adding a boolean field for the flagging and an array field with the user ids for the marking. This way I can use a boolean query to find flagged posts and for the favorite posts of a user I can use an exists query.
I'm pretty new to Elasticsearch so I'm not sure if this will perform good enough on millions/billions of posts. What other options are there?
Edit: Forgot to mention that I would also like to have paging for the blog posts and be able to filter out/in the flagged or marked posts. For example I want first (ordered by creation date) 10 blog posts that are marked as favorite, or last 10 blog posts flagged.
To make a favorite system one solution is to store the data in a different index with blog_id
user_id
created_at
This way you can easily add remove and search.
I want multiple users to be able to mark some blog posts as favorite
User 1 click on the favorite link of blog 2, system will store in "favorite" index {"user_id":1, "blog_id": 2, "created_at": "2019-10-02 12:00:02", "blog_created_at": "2019-01-01 09:10:11"}
only the user that did the marking is able to see it as marked.
You can search with get by id if you concaten the user_id-blog_id or you can make a search with blog_id, user_id and you can know if the record exist if the blog you display is marked as favorite by the user who read.
Same for list page as you know the user_id and after you build the list of blog_ids you'll display you can make the search and retrieve a list that you will use when you'll display your list of blogs.
This solution will have good performance even for billions of posts.
If you have flag you can also flag your blog post the same way and put a category field.
Depends on how much flag and which kind of flag you'll have you can consider saving in the same index with a category field ['favorite', 'flag', ...] or save in different indices.
Also another thing to check about is using periodic index (monthly, weekly or daily) depend on the number of document you will store and how much update (add/remove favorite) you will have. You can rollup your index in yearly later if you have lass activity on them.
And a last thing, maybe consider using cache to handle frenetic click on favorite button that can lead to add/remove document which will increase the number of deleted document in your index, that can make your index slow.
Edit for the Edit in the question:
For example I want first (ordered by creation date) 10 blog posts
that are marked as favorite, or last 10 blog posts flagged.
You can add the blog creation date in your favorite records "blog_created_at" (I updated the example document). So you can sort by blog creation date and limit your aggregation at 10 if you want the 10 first.
For the other case in your comment:
If I want to get just 10 blog posts, ordered by date, which are not
marked as favorite or not flagged
You can add a field in your blog and set as True if you have a favorite, something like "has_favorite" or "has_flag".
You set as True when you first set as favorite, if it's already favorite you do nothing.
So you can search against this field to filter the blog that don't have favorite.
If somebody remove a favorite you can count how much this blog have favorite if 0 set has_favorite to False. <-- only this case can generate update but it's maybe 0.001% of case so better to focus on the 99% of case. If it increase, need to adapt the solution.

Display the list of products in a tab

In my magento application i want to create a module which is for adding FAQ for a individual product. So while adding the FAQ, in the new tab i want to show the list of all products(like product listing) for which product we want to add FAQ.
So please help me how to customize for getting list of products and display in the new tab?
The question is too broad friend. So don't hope any full solution here. That is because, this question is related to an external extension. But you will get guidance here. Here you may need to do following things.
I think in admin, the extension provides provision to manage each individual faque. What you need to do is, you need to create an extra field that will relate that faq with a product or multiple products.
If you set up this, you need to store this information in database. So for each faq, there may be a product id or multiple product ids related to it
Now you need to create a new block for your extension. This block will filter faqs that related to a particular product.
Next step is add above block in layout. Layout handle you need to use here is catalog_product_view.
Create a new template for your custom block and in that template file, you need to put design codes. You can create this template with the help of current template that this extension uses. That way, you can reduce a lot of time for creating the design.
Hope that helps !

Magento Custom Module Grid Serializer

I am working on a custom Magento module to enter Composer information (name, bio, birth, death, etc.) and associate products (songs) with the composer. The module contains two tabs, one for the general info and the other for a list of the products (songs). The association should work exactly as the functionality of Related Products, Up-sells, and Cross-sells in the Product editing page. I feel like I've been running around in circles on a few points in regards to paging through the available songs and selecting and saving the entries. It's mainly dealing with the Grid Serialization. I've looked through as many resources as I can find, including several tutorials, without any luck:
http://magebase.com/magento-tutorials/understanding-the-grid-serializer-block/
I've posted the relevant files at this Gist and would appreciate any feedback or discussion. The files have a lot of material commented out from trying various solutions but they may prove useful in terms of thought process. Certainly available to post any other files that may be relevant.
I think this answer is exactly what you need. I know that single link answers are not very appreciated but the answer is kind of long to replicate in here.
You can also use this module creator to create you module (also available on magento connect). It has an UI that let's you create the modules in a similar way with how you create a table using phpMyAdmin. For each entity you create in your module you have the ability to say "Link many to many with products". This will create the the relation table between products and your entity and the second tab in the admin where you can choose products that are associated with your entity. Exactly like the products in the categories or like related products.
I admit that I'm the developer of the extension, but this should not be considered as spam since the extension is free and I get no profit out of it.

Magento: Add New Field to Credit Card Form

I'm trying to modify the credit card form to add some new custom fields named "Bank Name" and "Bank Phone Number" and it seems this cannot be done through the back-end.
I've searched the web and on here but I haven't been able to find anything in reference on how to add a new custom field to the credit card form. I would think it's almost the same as adding a new field to the customer registration form but I have no clue what to do database wise.
If anyone has anything I can use to work on this, I'd greatly appreciate it.
You should start by informing which version of Magento you are using and which methods you have already tried.
Without knowing that it is hard to help you, but you might want to try this possible solution, this one, or even one of these modules: Checkout Fields Manager or ADDITIONAL CHECKOUT ATTRIBUTES. If none of the above work, try this search.
No, Magento admin panel will not add custom columns for you. You need to do it yourself.
First, you need to edit the .phtml file to include these two fields to show up in frontend.
Second, you need to add two new columns (with same name as your fields, explained later) in relevant DB table (i guess sales_flat_order_payment). But that will affect for all payment methods, so define it something like VARCHAR(255) NULL.
Third, when Magento saves the CC info, you need to check if it is saving whole data array, then your field's name posted will match your table field and get inserted automatically. Else you need to edit it.
Also, next time please post some code, atleast something you have tried.

Retrieving articles based on custom URL parameters

I'm a beginner using Joomla 1.5. I have a page which shows articles in a blog format. My objective is to show/filter the articles per year (which isn't that many) based on user input. I'm planning to create a module on the right side, showing a dropdown box of the years, and retrieve the results by passing the year parameter as part of the URL
Ex.
http://sample.com/index.php?option=com_content&view=category&layout=blog&id=39&Itemid=24&year=2011
What is the best, simplest way of passing and processing additional parameters to com_content via URL? Can I do so using extensions such as K2 and flexicontent? If not, can someone advise me what code to add and where, in com_content? If I have to extend com_content itself, can someone guide me how to or point some useful articles?
Appreciate the help. Thanks
I don't know if K2 or flexicontent offer this option, but com_content appears NOT to have this feature.
I would just build a module, create a query and use the table jos_content, select only the fields that you need (like title) and check the field created to be in the year you need.

Resources