Jump to content

Reassign Pricing should also update package_group_id


Jonathan

Recommended Posts

i think it does it . when i reassing pricing it update the package group id .

Update : No it doesn't update it, we have tried it and have found another issue in the above thread , i we have update our custom plugin convert package to make this updated . i think the update is simple, i will put what we have do in our plugin later this day .

 

Link to comment
Share on other sites

this is our fix :

in models/reassign_pricing_services.php replace the edit fucntion with this :

    public function edit($service_id, array $vars)
    {
        $vars['service_id'] = $service_id;
        $vars['module_row_id'] = $this->getPackageModuleRow($this->ifSet($vars['pricing_id']));
        $vars['package_group_id'] = $this->getPackageGroupId($this->ifSet($vars['pricing_id']));
		
        $this->Input->setRules($this->getRules($vars));

        if ($this->Input->validates($vars)) {
            $this->Record->where('id', '=', $service_id)
                ->update('services', $vars, ['pricing_id', 'module_row_id', 'package_group_id']);
        }
    }

add this function before the last line

	/**
     * Retrieves the Package Group Id associated with the given package pricing
     *
     * @param int $pricing_id The package pricing ID
     * @return mixed The Package Group Id if it exists, or null otherwise
     */
    protected function getPackageGroupId($pricing_id)
    {
        $package = $this->Record->select(['package_group.package_group_id'])
            ->from('package_pricing')
            ->innerJoin('packages', 'packages.id', '=', 'package_pricing.package_id', false)
            ->innerJoin('package_group', 'package_group.package_id', '=', 'package_pricing.package_id', false)
            ->where('package_pricing.id', '=', $pricing_id)
            ->fetch();

        return ($package ? $package->package_group_id : null);
    }

hope it will help .

Link to comment
Share on other sites

  • 3 months later...
22 hours ago, Jonathan said:

This should be treated as a bug.  It breaks addons which look at package_group_id to see if they should be available or not.

When this is patched a way to scan/fix the DB should also be released.  Should be pretty easy since Blesta knows what package_group_id goes with what pricing_id.

This issue is also affect the importer plugin, all the services imported has package_group_id as null, then all the addons will not be shown for them, they are shown only for newly created services. i have reported this a years ago but not fixed .

Link to comment
Share on other sites

  • 1 month later...
1 hour ago, Jonathan said:

Any updates on getting this fixed in core?  It prevents a service from seeing the correct addon packages available and has no fix except manually in the database.

How do we know what package group to assign it to? The new package could belong to 1 or more groups.. or maybe this should be an option in the UI when reassigning pricing? We have a Package/Term option, maybe we should populate a Package Group option for all package groups the selected Package is part of, and you can choose.

Link to comment
Share on other sites

20 hours ago, Paul said:

How do we know what package group to assign it to? The new package could belong to 1 or more groups.. or maybe this should be an option in the UI when reassigning pricing? We have a Package/Term option, maybe we should populate a Package Group option for all package groups the selected Package is part of, and you can choose.

What logic is used to assign it when a service is added?  The same logic should be used to keep it associated with the correct module of the pricing_id.

Link to comment
Share on other sites

3 hours ago, Jonathan said:

What logic is used to assign it when a service is added?  The same logic should be used to keep it associated with the correct module of the pricing_id.

When a service is added, the package group is known. In the case of the order form, the client selects the Package within the Package Group. In the case with Staff, it's listed underneath the Package Group name in the package selection drop down. If you are changing it using re-assign pricing, any package of like module can be selected, regardless of Package Group. And the Package could belong to one or more package groups.

I think we need to add a second drop down menu after selecting the package / pricing to select the package group. I don't know if there is a need for using packages without being assigned to a group, since these cannot typically be ordered.

See attached screenshot. Reassign pricing has the package as the label. Adding a service has the Package Group as the label.. so when re-assigning pricing, we do not know what the package group should be.

reassign-pricing.png

Link to comment
Share on other sites

6 minutes ago, Jonathan said:

That seems a logical solution then.  We don't use packages in multiple groups together but I'm sure others do.

Perhaps it wouldn't take much logic for if the target package is only in one group for it to do the logic automatically?

We definitely don't want to assume, since packages can belong to multiple groups, even if most people don't assign them that way. If there is only one group, then maybe the dropdown can default to that so there's no extra effort required. Anyway, created CORE-2627 to address.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...