concretecms-community-store / community_store

An open, free and community developed eCommerce system for Concrete CMS
https://concretecms-community-store.github.io/community_store/
MIT License
106 stars 66 forks source link

Fix creating products with variations when "auto qty" is enabled #836

Closed mlocati closed 5 months ago

mlocati commented 5 months ago

When the "Calculate automatically the quantities for products with variations" option is enabled, we may encounter this error when creating a new product with variations:

Doctrine\DBAL\Exception\DriverException thrown with message
"An exception occurred while executing
'INSERT INTO CommunityStoreProducts
(cID, pName, pSKU, pBarcode, pDesc, pDetail, pPrice, pWholesalePrice, pCostPrice, pSalePrice, pSaleStart, pSaleEnd, pCustomerPrice, pPriceMaximum, pPriceMinimum, pPriceSuggestions, pQuantityPrice, pFeatured, pQty, pQtyUnlim, pDateAvailableStart, pDateAvailableEnd, pOutOfStockMessage, pAddToCartText, pBackOrder, pNoQty, pAllowDecimalQty, pQtySteps, pQtyLabel, pMaxQty, pTaxClass, pTaxable, pfID, pActive, pDateAdded, pDateUpdated, pShippable, pWidth, pHeight, pStackedHeight, pLength, pWeight, pNumberItems, pSeperateShip, pPackageData, pCreateUserAccount, pAutoCheckout, pOrderCompleteCID, pExclusive, pVariations, pNotificationEmails, pManufacturer, pType)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
with params [0]:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens"

(please remark the empty params).

I think the solution is to use recomputeSingleEntityChangeSet() instead of computeChangeSet() (at least this seems to fix this issue).