Blesta Addons Posted July 12, 2016 Report Posted July 12, 2016 In import manager . The package_group_id in services always null by default . This impact the package addons related to that services . Sinse is null the client can't add any addons options. Please check this thread http://www.blesta.com/forums/index.php?/topic/6769-client-cant-add-addons-package/ Michael 1 Quote
Blesta Addons Posted July 15, 2016 Author Report Posted July 15, 2016 i need i feedback from staff about this issue . what is the best way to fix this issue ? Quote
Paul Posted July 19, 2016 Report Posted July 19, 2016 This is a result of importing? I would expect services.package_group_id to be null if importing from Blesta 2.5 because 2.5 did not support package groups. The solution would be to update services.package_group_id so that it matches the desired package group. Then you should be able to upgrade/downgrade between other packages in the same group that match the same module. Michael 1 Quote
Blesta Addons Posted July 20, 2016 Author Report Posted July 20, 2016 yes , is a result of importation from v 2.5 i know the solution is to update the services.package_group_id . my concern here that we have more than 10000 services , and i can't play and testing in a live environement , i need a solid php code to update the fields . i hope tyson or cody can give a sample code that can be do the job . Quote
Blesta Addons Posted July 20, 2016 Author Report Posted July 20, 2016 s this code safe ? $fields = array( "services.*", 'pricings.term', 'packages.id' => "packages_id", 'package_group.package_group_id' => "filled_package_group_id", 'packages.name', 'contacts.company' => "client_company" ); $this->Record->select($fields)-> from("services")-> innerJoin("package_pricing", "package_pricing.id", "=", "services.pricing_id", false)-> innerJoin("pricings", "pricings.id", "=", "package_pricing.pricing_id", false)-> innerJoin("packages", "packages.id", "=", "package_pricing.package_id", false)-> innerJoin("package_group", "package_group.package_id", "=", "packages.id", false)-> innerJoin("clients", "services.client_id", "=", "clients.id", false)-> innerJoin("client_groups", "client_groups.id", "=", "clients.client_group_id", false)-> on("contacts.contact_type", "=", "primary")-> innerJoin("contacts", "contacts.client_id", "=", "clients.id", false); // Filter on client ID if ($service_id != null) $this->Record->where("services.id", "=", $service_id); $this->Record->where("services.status", "!=", "canceled")-> where("services.package_group_id", "=", null); // Ensure only fetching records for the current company $this->Record->where("client_groups.company_id", "=", Configure::get("Blesta.company_id")); $services = $this->Record-> fetchAll(); foreach ($services as $service) $this->Record->where("services.id", "=", $service->id)->update("services", array('package_group_id' => $service->filled_package_group_id)); activa 1 Quote
Tyson Posted July 20, 2016 Report Posted July 20, 2016 I haven't looked at the importer, but from your code I don't see any problems. You may want to group on the service ID though. You mentioned you have 10k services. Fetching them all at once may exhaust memory. You can iterate over the records instead: ... $services = $this->Record->group(array('services.id'))->getStatement(); foreach ($services as $service) { $this->Record->where("services.id", "=", $service->id)->update("services", array('package_group_id' => $service->filled_package_group_id)); } Michael 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.