Broadleaf Commerce - Enterprise eCommerce framework based on Spring
core/src/main/resources/META-INF/persistence-core.xml
. So something like this:<persistence-unit name="blPU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>jdbc/web</non-jta-data-source>
<class>com.blcdemo.core.domain.PDSiteImpl</class>
<exclude-unlisted-classes/>
</persistence-unit>
Hi @danielcolgrove
I'm using the existing persistence unit. I would like to create my own MyCustomerPhone.orm.xml in the core module and I need to add the mapping file in core/src/main/resources/META-INF/persistence-core.xml. But it is unable to create the bean and it has started throwing me an error during server startup.
Please let me know the steps for registering a new ORM file and registering it.
CorePersistenceConfig.java
class I see that we have a PersistenceXMLLocations merge setup. I would start there and add your own to that array/list.@Merge(targetRef = "blMergedPersistenceXmlLocations", early = true)
public List<String> corePersistenceXmlLocations() {
return Arrays.asList("classpath*:/META-INF/persistence-core.xml");
}
@chiranjitsaha1108,
We are using the standard Spring logback mechanism. Having a logback.xml in the classpath is all that is needed. I went ahead and committed a beginning logback.xml file into the Demo project in the develop-6.1.x branch:
https://github.com/BroadleafCommerce/DemoSite/tree/develop-6.1.x/core/src/main/resources
You can enable Hibernate logging by adding the following to the logback.xml file:
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
Hi @chiranjitsaha1108 The LegacyOrderService was deprecated in 2012. See this commit - BroadleafCommerce/BroadleafCommerce@2db5e7a
The OrderServiceImpl took it's place and that is the service in use out of the box. The implementation can be found here https://github.com/BroadleafCommerce/BroadleafCommerce/blob/develop-6.0.x/core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/order/service/OrderServiceImpl.java
There is already an OrderLock in place via the CartStateFilter. See https://github.com/BroadleafCommerce/BroadleafCommerce/blob/develop-6.0.x/core/broadleaf-framework-web/src/main/java/org/broadleafcommerce/core/web/order/security/CartStateFilter.java. In addition, there is a transaction in place which is managed in the OrderServiceImpl class.
The code is available for these classes and you can change the implementation as needed.
Hi @danielcolgrove
I would like to implement a cache in the core part . For which the cache will hold order-related information. This cache will be unique to every order. Can you please let me know the process of creating an order level cache?
Also registering the cache in the core module.
@chiranjitsaha1108 You can register a cache in the bl-override-cache.xml file. See https://www.broadleafcommerce.com/docs/core/current/broadleaf-concepts/additional-configuration/caching-configuration. You can also see examples of cache entries in the core code - https://github.com/BroadleafCommerce/BroadleafCommerce/blob/develop-6.1.x/common/src/main/resources/bl-common-ehcache.xml
The framework usually handles caching via Hibernate's L2 cache. This is setup on each individual domain class and in the DAOs as query hints. You can find examples in the core code. See
OrderImpl.java (@Cache annotation)
https://github.com/BroadleafCommerce/BroadleafCommerce/blob/82a6b4da47a69da51cb9091714c8d7779a26c362/core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/order/domain/OrderImpl.java#L105
OrderDaoImpl (query.SetHint)
https://github.com/BroadleafCommerce/BroadleafCommerce/blob/82a6b4da47a69da51cb9091714c8d7779a26c362/core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/order/dao/OrderDaoImpl.java#L131
A second approach is manually managing the cache. This approach is less frequent but there are examples. See
So either of the two approaches are valid. The approach depends on what your specific implementation. Note that the links above are the 6.1.x. If you are using a version < 6.1.x you should select that specific documentation set or github branch.
Hi @danielcolgrove
Please tell me one scenario that is there any OOTB functionality is given that I want to hold a transient java collection variable at order level and it is valid as long as the user is Active or logged in.
Please let me know the procedure that I need to follow to hold a transient variable in order level and it will be active throughout the session.
Hi @danielcolgrove
Can you please provide me an example of useing Quartz or scheduler in Broadleaf commerce. Is it we are storing the details in the DB or in memory (RAM) used to hold the information and execute the scheduler.
Kindly provide me an example class in BLC through which I can understand more about the architecture followed in BLC.
Hi @danielcolgrove
There is a property in BLC_SKU for QUANTITY_AVAILABLE.
Is there any OOTB method through which I can decrease the quantity value for a SKU once the order is placed?
Or do we need to write a custom code in the workflow to decrease the quantity once the order is placed?
Also is it valid to update the BLC_SKU entity to decrease the value of SKU quantity manually?
@chiranjitsaha1108,
There is already a workflow defined for decrementing inventory on checkout:
https://github.com/BroadleafCommerce/BroadleafCommerce/blob/develop-6.1.x/core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/checkout/service/workflow/DecrementInventoryActivity.java
Here is the workflow definition:
https://github.com/BroadleafCommerce/BroadleafCommerce/blob/5267f387667ad34ed8e847a2ce0a3d4a779f9bdd/core/broadleaf-framework/src/main/resources/bl-framework-applicationContext-workflow.xml#L208
To manually increase/decrease inventory, there is an InventoryServices that can be used:
Hi @danielcolgrove
For Google analytics Integration in Broadleaf 6.0, is any other step required other than the below ones:
Generated Google Analytics Tracking Id
placed the tracking id in the googleAnalytics.webPropertyId
Please let me know if any other steps are required to enable the google analytics also do we need to write any separate code for enabling google analytics.
Also please let me know how can I enable search typeahead suggestion while searching some products on Broadleaf demo site 6.0.
Hi @danielcolgrove
Can you please let me know how can I generate the sitemap.xml file. Do I need to create any folder in the core module so that the sitemap xml file will be generate. I have executed the sitemap url - sitemap.xml.
Also please tell me if there is already default web page provided for viewing the genetated sitemap.
Demosite 6.0 Im currently using.
Hi @riteshadhikari17
Thanks for the response and I have gone through the file already. But the problem that I'm facing currently is the sitemap is not getting generated. Do I need to create a package to any specific location with a default file. So that file will exist and it can write on the same file?
Also how to display it in the HTML - Is there any default HTML page present to categorize the content?
site/src/main/java/com/community/controller/seo/SiteMapController.java
. You should be able to hit localhost like this https://test.localhost:8443/sitemap.xml
Hello there, I am a broadleaf 6.2v new user. For 3 days, I am trying to add my own created controller, service, dao and entity. But because of @PersistenceContext(unitName="blPU")
protected EntityManager em;
those lines from the 'MailInfoDaoImpl' class of 'Core', i am facing an error :
APPLICATION FAILED TO START
Description:
A component required a bean named 'blPU' that could not be found.
Action:
Consider defining a bean named 'blPU' in your configuration.
this kind of error but without '@PersistenceContext(unitName="blPU")'(when comment out), I am also facing an another error from 'Admin' part which is from 'MyController'[note: newly created & extends AdminAbstractController] :
APPLICATION FAILED TO START
Description:
A component required a bean named 'blMailInfoService' that could not be found.
Action:
Consider defining a bean named 'blMailInfoService' in your configuration.
--> This may occur because of those lines when I trying to call the service from 'Core' to 'Admin':
@Resource(name = "blMailInfoService")
protected MailInfoService mailInfoService;
[Q. is any config needed in 'Admin']
Please help me & Thanks in advance.
EmailReportingDaoImpl
or ProductDaoImpl
to correctly use the EntityManager. Tutorials for services are here and More detailed info here