I have to open minicart box after addtocart button click. Is it possible to using section.xml? Anyone know about sections.xml usage in magento2?
What are exactly those sections?
A section is a piece of customer data grouped together. Each section is represented by the key that is used to access and manage data and data itself. Magento loads sections by AJAX request to /customer/section/load/ and caches loaded data in the browser local storage under the key mage-cache-storage. Magento tracks when some section is changed and load updated section automatically.
How do you define a section?
A section defined in di.xml file by adding a new section into sections pool
<type name="Magento\Customer\CustomerData\SectionPoolInterface">
<arguments>
<argument name="sectionSourceMap" xsi:type="array">
<item name="cart" xsi:type="string">Magento\Checkout\CustomerData\Cart</item>
<item name="directory-data" xsi:type="string">Magento\Checkout\CustomerData\DirectoryData</item>
</argument>
</arguments>
So here two new sections are registered cart and directory-data. Magento\Checkout\CustomerData\Cart and Magento\Checkout\CustomerData\DirectoryData implements Magento\Customer\CustomerData\SectionSourceInterface and provides actual data as result of getSectionData method.
How are the section updates triggered?
Magento assumes that customer's private data is changed when a customer sends some state modification requests (POST, PUT, DELETE). To minimize the load on the server, developers should specify which action (or request) updates which customer data section in etc/section.xml.
<action name="checkout/cart/add">
<section name="cart"/>
</action>
Action name is an action key pattern. When a user calls to action that matches specified pattern Magento will detect that the corresponding section is outdated and loads it again. If the action name is * that means that section will be updated on each POST and PUT request. If section tag is missed then all sections will be updated.
So conceptually this is wrong to update mini cart when you rich cart page. At this point, the mini cart (or cart section) already should be updated.
You can find more information about Customer Data here
There is already a full-fledged free extension available on Magento's marketplace and Github
magento: https://marketplace.magento.com/ambab-module-slidingcart.html
Github: https://github.com/ambab-infotech/slidingcart
This might help someone.
Reference URL: https://roshanyadav007.wordpress.com/2020/01/24/sliding-cart-extension-for-magento-2-magento-2-3-x/
Related
I want to add a "payonbill" feature for my shop so i am using the checkmo payment method to do so. I added a new module with this configuration:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<payment>
<checkmo>
<active>1</active>
<model>Magento\OfflinePayments\Model\Checkmo</model>
<order_status>processing</order_status>
<title>Check / Money order</title>
<allowspecific>0</allowspecific>
<group>offline</group>
<payment_action>authorize_capture</payment_action>
</checkmo>
</payment>
</default>
</config>
By doing so that payment status will migrate to processing and the payment action will be triggered for authorization. When doing so i am no longer able to even place an order on the shop for this method. The problem actually is there because of the payment_action. When i remove that it works again.
Is there a way to handle this scenario? When someone can pay on bill i would like to trigger the event sales_order_invoice_pay as well and continue the flow.
Best
Pim
I fixed the issue by actually removing the stuff i previously did and by implementing this module:
https://github.com/dominicwatts/autoinvoice
The actual problem was that all was working fine but in the end for the offline payment the invoice is generated when booking it inside admin. Bypassing the status won't generate the invoice for you.
In Jasper Server Community Edition, I want to load a report automatically without clicking on any report when I logging. I tried to add below code to home.jsp page as jasperSoft documentation says.but it is not working.
Please help me with this.
Code that I added to home.jsp :-
<%
<authz:authorize ifAllGranted="ROLE_REPORT_HOME">
<c:redirect
url="http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2Freports&reportUnit=%2Freports%2FSample_Dash_Report&standAlone=true"/>
</authz:authorize>
%>
Please make sure to follow all the steps in the tutorial, as you probably missed to add user role to the user you want. Also, make sure to have sample data as you're referencing report from sample data.
Setting a report as the home page:
The following example shows how to set a report as the home page based on a role. This example uses the 01. Geographic Results by Segment Report.
First, set up the role and create a sample user:
a. Create the role you want to use, for example, ROLE_REPORT_HOME.
b. Create a user HomeUser and add ROLE_REPORT_HOME to HomeUser.
Open the file \WEB-INF\jsp\modules\home\home.jsp in an editor and add the following lines:
<authz:authorize ifAllGranted="ROLE_REPORT_HOME">
<c:redirecturl="http://localhost:8080/jasperserver-pro-601/flow.html?_flowId=viewReportFlow&standAlone=true&_flowId=viewReportFlow&ParentFolderUri=%2Fpublic%2FSamples%2FReports&reportUnit=%2Fpublic%2FSamples%2FReports%2F01._Geographic_Results_by_Segment_Report"/>
</authz:authorize>
To find the URI for the report you want to use, open the report in the repository and copy the URI.
Save the modified file and restart the application server to see changes.
Log into JasperReports Server as HomeUser. The library page is displayed.
Go to Jasper server installation directory and search for jasperserver-servlet.xml (C:\Jaspersoft\jasperreports-server-cp-6.4.2\apache-tomcat\webapps\jasperserver\WEB-INF\jasperserver-servlet.xml)
Under bean id = "homePageByRole" we have to make changes. For that, search homePageByRole word inside the jasperserver-servlet.xml file.
Under tag ,we can give a report link we need according to the user roles. But make sure you should add amp; as after each & mark. Otherwise it will give an error!
Example:-
Original report link from the address bar in browser when report opened using jasper server is;
http://localhost:8080/jasperserver/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2FMy_Reports&reportUnit=%2FMy_Reports%2FDashboard_Report_Landscape&standAlone=true
But the link we should put under is;
ROLE_USER|redirect:/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2FMy_Reports&reportUnit=%2FMy_Reports%2FDashboard_Report_Landscape&standAlone=true
check how we add as amp; after every & mark. Also we can set user role. In my case I set user role as ROLE_USER.
Whole code snippet is;
<bean id="homePageByRole" class="java.util.ArrayList">
<constructor-arg index="0" type="java.util.Collection">
<list>
<value>ROLE_ADMINISTRATOR|redirect:/flow.html?_flowId=searchFlow</value>
<value>ROLE_USER|redirect:/flow.html?_flowId=viewReportFlow&_flowId=viewReportFlow&ParentFolderUri=%2FMy_Reports&reportUnit=%2FMy_Reports%2FDashboard_Report_Landscape&standAlone=true</value>
</list>
</constructor-arg>
</bean>
How can I add a new document to Content Server with Category Attribute value (BuilingId )using the postman
You are trying to do too much at once.
First add the file
then apply the category, then add the buildingID to the category.
See this thread on Appworks Site, top post explains that in detail.
Then once you are ready to edit the category...
Use the form id of the input box for BuildingID , for example
Key: "_1_1_13_1"
Value: "Your Data"
you will find this on the form itself in the html;
<textarea class="valueEditable multiline" ----> id="_1_1_13_1" <---- name="_1_1_13_1" title="BuildingID" rows="5" cols="64" onchange="markDirty();"></textarea>
The best thing to figure this out is to use Postman and Postman Interceptor from the Chrome App Store.
Using these you can see what the form is sending to the server when you normally submit the category info, then work backwards from there.
I have started designing addToCart method as HTTP POST in my RESTful API. This looks good when the client adds to cart a product first time (POST create a new entry on server). But, the same HTTP rule breaks when the client browses through the site and adds the same item again; where we should not create a new entry but only update the quantity of existing item.
Isn't using POST to update resource wrong? What is the way to implement this? or how to interpret this situation.
Note: Client/UI front which uses my api would not remember if its already there on server. Please consider any ecommerce application's addtocart as example.
I think the difficulties here are already present in how you add the original item to the cart.
When you add an item to cart, are you creating a new object (the item)? Or are you modifying an existing item (the cart)? To me it makes more sense to say the latter. POSTing an item seems like it should be reserved for a different situation, when you add a new item to your store.
Conceptually, the cart is then like a vector of all the items in your store, associated with a number (0 for almost all of them). Adding something to the cart means incrementing this number for one of the items, regardless of whether it is already more than 0.
You can use PATCH to send a part object / update to an existing object.
It's based on your model. IMHO a POST is also fine if you are modelling a new intent or cart-operation with it, which can be basically anything.
I'm building a custom module in SugarCRM Community Edition, I have everything set up as i'd like (almost).
In my Module i have a checkbox marked 'Processed' what i'd like to achieve is that when this checkbox is marked, the users who are 'sales agents' and not 'admins' can no longer view this record.
They need to be able to have access to the record up until the point it's marked as processed. Is this possible?
Yes, look at /modules/Employees/views/view.list.php in listViewProcess() to see how the list view always filters out users based on the status value. You would do something similar for your module to filter out Processed. Then if you need to also ensure that they can't access the record directly make sure to take care of the edit/detail views as well. In both view.detail.php and view.edit.php (or in the module's controller) check for Processed being set and if so (and perhaps not an admin or some other user type) display a "This record is already processed" message and/or do a redirection.