Forums › Forums › OroPlatform › OroPlatform – Programming Questions › Maximum business unit
This topic contains 7 replies, has 3 voices, and was last updated by dimitri.seguin17 8 years, 4 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- September 15, 2015 at 1:10 am #33937
Hello,
I have to open orocrm extranet, but I need over 15 000 business unit.
I have approximatively 16 000 business unit, I can’t login as admin.Is there a limit of business unit?
- CreatorTopic
- AuthorReplies
- September 15, 2015 at 1:35 am #33938
Hi Dimitri,
There are no limits for the number of business units in the system, so you may create as much as you need.
September 15, 2015 at 7:29 am #33939Ok thank’s for your answer
I actualy have a script that import approximatively 18 000 business unit in my orocrm instance.
This import run successuly.
But after the import when i want to connect as admin (role admin) to the oro http interface, i get an php timeout error.Does the number of business unit present in the db have a major impact on the performances, and can explain the error i have ?
the admin user belong to the ‘main’ business unitHave you an idea to solve this problem ? Or some advice on where looking for
September 16, 2015 at 7:31 am #33940After looking into oro code i found the timeout is due to the method OwnerTreeProvider.fillTree() that take very long time when the number of Business Unit grow.
I see that the result of this method is cache but i don’t understand the scope of this cache and how it is invalidate.
Does someone know if it is possible to prewarm this cache with a cron job to avoid timeout on http calls ?Thanks in advance
November 3, 2015 at 1:48 am #33941Hello, I want to update oroplatform code.
I want to change a user scope to global scope. In fact, warm the cache for all sessions and not for one session.
And when I have new business unit, whether rewarm all cache or just update cache with a new business unit.
It’s a good idea or not ?
November 3, 2015 at 9:17 am #33942Hi Dmitri
Why you would like to change users ownership type to system (we would like to understand the reason of the request)? The main idea behind current (business unit) ownership type is that each business units could manage own users. Changing ownership type for user will have very big impact on business logic and will not accept it without good reason behind.
Thanks
DimaNovember 4, 2015 at 8:47 am #33943Hi Dima,
Thanks for your answer.
i will try to be more understandable :)I don’t want to change the scope of the ownershop type.
I just suggest to change the scope of the cache that is construct when a user load. To allow all user to shared the same cache objet.
And update this cache at right change instead of user login.
But i’m not sure to understand all the implications of this change.
Maybe there is a better way to fix the performance issue i have when i add a lot of business unit in my instance.
What was the best way to build this cache object at an another moment than the user login ?Thanks in advance,
RegardsDimitri
November 18, 2015 at 2:42 am #33944Hello,
Finaly i understand that the performance problem came from the method OwnerTreeListener:checkEntities() that consider the OwerTreeProvider cache must be invalidate because the User Entity was change. Fields login_count and last_login were change due to login but theses two fields are not involved in the cache calculation.
So i modified the OwnerTreeListener:checkEntities() like below to exclude theses fields of the changes check.
With modifications the OwerTreeProvider cache is no more rebuild at each login and i have no more performance issue when i import a lot of Business Unit.
protected function checkEntities(array $entities)
{
$uow = $this->container->get('doctrine.orm.entity_manager')->getUnitOfWork();foreach ($entities as $entity) {
if (in_array(ClassUtils::getRealClass($entity), $this->securityClasses, true)) {
if(get_class($entity) == 'Oro\Bundle\UserBundle\Entity\User') {
$att = $uow->getEntityChangeSet($entity);
if(!array_key_exists('lastLogin', $att) && !array_key_exists('loginCount', $att) && count($att) === 2) {
return true;
}
}
}
}
return false;
}
I also import Business Unit with a cli import command that create new BusinessUnit with the following code :
public function addBusinessUnit($name, $business_unit_owner_id = null, $phone = null, $website = null, $email = null, $fax = null)
{
$businessUnit = new BusinessUnit();$businessUnit->setOrganization($this->organization_manager->getOrganizationById(1));
$businessUnit->setName($name);
$businessUnit->setPhone($phone);
$businessUnit->setWebsite($website);
$businessUnit->setEmail($email);
$businessUnit->setFax($fax);
$businessUnit->setOwner($business_unit_owner_id);$this->em->persist($businessUnit);
$this->em->flush();return $businessUnit;
}
I notice that the OwerTreeProvider cache was not clear when i import BusinessUnit through doctrine persist().
So i also change the AbstractOwnerTreeProvider::ensureTreeLoaded() to be public instead of protected to call this method at the end of my Business Import Script.Should i make a pull request with theses two changes in the ORO code ?
Thanks for your reply,
Regards,Dimitri
- AuthorReplies
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.