Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Import of quotes from csv not working - import matches items that has been deleted, fix included to make query check crmentity deleted column #17423

Open
WMCyn opened this issue Apr 15, 2024 · 4 comments

Comments

@WMCyn
Copy link

WMCyn commented Apr 15, 2024

trying to import quotes using csv.

export a test quote from yeti to get formatting.

removed test quote and attempted to import from exported csv

system just gives error
image

Nothing showing logs

Am I missing something?

@WMCyn
Copy link
Author

WMCyn commented Apr 15, 2024

Think I have found the issue, the "product name" in the quote matched both a deleted product and a newer product.
after turning on more logging.
it was attempting to match the "product name" with the one marked as deleted.

Any idea where in the code to make the import respect the "deleted" flag?

@WMCyn
Copy link
Author

WMCyn commented Apr 15, 2024

problem is in \app\record.php

public static function getCrmIdByLabel($moduleName, $label, $userId = false)
{
	$key = $moduleName . $label . '_' . $userId;
	if (\App\Cache::staticHas(__METHOD__, $key)) {
		return \App\Cache::staticGet(__METHOD__, $key);
	}
	$query = (new \App\Db\Query())
		->select(['cl.crmid'])
		->from('u_#__crmentity_label cl')
		->innerJoin('vtiger_crmentity', 'cl.crmid = vtiger_crmentity.crmid')
		->where(['vtiger_crmentity.setype' => $moduleName])
		->andWhere(['cl.label' => $label]);
	if ($userId) {
		$query->andWhere(['like', 'vtiger_crmentity.users', ",$userId,"]);
	}
	$crmId = $query->scalar();
	\App\Cache::staticSave(__METHOD__, $key, $crmId);

	return $crmId;
}

@WMCyn
Copy link
Author

WMCyn commented Apr 15, 2024

notice no check for "deleted"

@WMCyn
Copy link
Author

WMCyn commented Apr 15, 2024

fixed version of the function

public static function getCrmIdByLabel($moduleName, $label, $userId = false)
{
	$key = $moduleName . $label . '_' . $userId;
	if (\App\Cache::staticHas(__METHOD__, $key)) {
		return \App\Cache::staticGet(__METHOD__, $key);
	}
	$query = (new \App\Db\Query())
		->select(['cl.crmid'])
		->from('u_#__crmentity_label cl')
		->innerJoin('vtiger_crmentity', 'cl.crmid = vtiger_crmentity.crmid')
		->where(['vtiger_crmentity.setype' => $moduleName])
    	->andWhere(['vtiger_crmentity.deleted' => 0])
		->andWhere(['cl.label' => $label]);
	if ($userId) {
		$query->andWhere(['like', 'vtiger_crmentity.users', ",$userId,"]);
	}
	$crmId = $query->scalar();
	\App\Cache::staticSave(__METHOD__, $key, $crmId);

	return $crmId;
}

@WMCyn WMCyn changed the title [bug] Import of quotes from csv not working [bug] Import of quotes from csv not working - import matches items that has been deleted, fix included to make query check crmentity deleted column Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant