Jump to content
Jonathan

Reassign Pricing should also update package_group_id

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 .

 

Share this post


Link to post
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 .

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×