Very useful information, thank you. While each answer didn't necessarily provide the sought information, the other information filled in many of the gaps.
Ok, so a couple of things I see... The query: 'UPDATE products_with_attributes_stock set `quantity` = 10, `customid = 'ASH_GOOD_S', `title` = 'POS: Ash, Good..., S', `barcode` = null WHERE `products_id` = 706 AND `stock_attributes` = '163755,163806"
has a mistake in it, though I don't know if that was manually typed or copy/pasted. After `customid there should be another backquote (on US keyboard the key in the upper left corner in combination with the tilde (~).)
As far as uniqueness, based on what I'm seeing in admin/includes/classes/products_with_attributes_stock.php at/around line 716:
Code:
$query = "SELECT count(*) AS total FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " WHERE (products_id = :products_id: AND stock_attributes = :stock_attributes:) " . (isset($productAttributeCombo) ? "OR product_attribute_combo = :product_attribute_combo: " : "") . (isset($customid) /* @TODO if customid is not required to be unique then and with a false */ ? "OR customid = :customid:" : "");
It appears that a duplicate/existing record is being found based on this query or the query as modified to support `barcode`.
The goal of this query is to use the provided information that determines if a lookup identifies a duplicate entry in the pwas table. Based on what happens next, it seems that there is a duplicate found. If the query is unmodified to support the additional field, then it would seem that the customid is non-unique. This is first based on the fact that it seems that the combination of products_id and stock_attributes being entered does not exist (report of variant not being in the list nor in the database) and that just before this call, the product_attribute_combo is generated to equal the combination of those two fields which since that original combination doesn't exist I wouldn't expect this one to exist either. Therefore, the only remaining "duplicate" is the customid of 'ASH_GOOD_S'. Please confirm that customid already exists in the database for any product. If it does not, please identify how this query is otherwise different than originally provided.
Then, if the customid actually is the duplicate record, then it would seem that the next "duplicate" searching query has not been updated to further reflect the comparison criteria or I have a problem with the evaluation that immediately follows. The words/concepts "seem" right, but the results don't seem to match. The query I'm speaking to is:
Code:
"SELECT count(*) as total FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " WHERE ((products_id = :products_id: AND stock_attributes = :stock_attributes:) " . (isset($productAttributeCombo) ? "OR product_attribute_combo = :product_attribute_combo: " : "") . ") AND `customid` != :customid:";
// If find a record, then the customid was assigned to some other product or the two parts of the where
As the logic is this: have already found that the earlier query identified one or more records searched on an 'or' basis. Because we are talking about whether the customid is unique or not, it could be that the customid is already assigned to this one product or it could have been used in multiple places... If it is already assigned to this one product, then it is fine that the customid "already" exists because the customid identifies to this product... But, if the customid is used elsewhere, then attempting to apply the customid to this record would mean that at least a duplicate exists, could be used more times than one. So... This query is expected to identify if the combination for this variant exists where the variant is not assigned to the current customid (with the customid not being empty)...
There may be an incorrect action after this for not finding a match, but I think at this point it would be good to get the results from above first... I know that I had made changes to the "duplicate" customid inspection some time ago with the possibility of not requiring a unique customid for all variants.
Bookmarks