Float stock for products migration concept

Edit on GitHub

We have changed the type of stock and quantity fields from int to float. With this change, we allow to manage fractions of items in the system.

As stock and quantity are very basic concepts of any commerce system, changing their type is a horizontal barrier for the modules. This means that, if a module is upgraded to a version that uses float stock, all the other modules in the project which are involved in the float stock barrier must be upgraded to avoid accidental type incompatibilities. For example, if ModuleX uses float stock and ModuleY uses int stock and there is no hard dependency between them, it’s technically possible to upgrade only one of them, however, during runtime, both modules may happen to process the same request data and, as a result, the response will either be calculated incorrectly or a fatal error will be thrown due to a data type mismatch.

In case of upgrading one of the modules involved into the float stock concept, we strongly recommend upgrading all the modules in your project from the list below. Mostly, the migrations have very low or even zero effort, because they only break type of a transfer object or an internal function’s signature. Some modules changed database field types to DOUBLE which is automatically upgradable by running the necessary console commands.

If you upgrade to the float stock concept, you should also review your project code and make sure to adapt all stock and quantity related customizations and implementations to use float type accordingly. If you have any partner or ECO integrations, they might have to be adjusted too.

Here are some typical occurrences of working with stocks and quantities and tips to make them compatible with the float type:

  • Product stock and availability management - use UtilQuantityService to handle arithmetic operations with float quantity values.
  • Cart item management - use UtilQuantityService to handle arithmetic operations with float quantity values.
  • Price calculations - use UtilPriceService to handle rounding of price values in a centralized way and avoid handling money fractions.

Migration Process

You can try to upgrade all affected modules together by following the steps below.

  1. Update the modules:
composer update "spryker/*" "spryker-shop/*"
composer require spryker/availability:"^7.0.0" spryker/availability-cart-connector:"^5.0.0" spryker/availability-gui:"^4.0.0" spryker/availability-offer-connector:"^2.0.0" spryker/cart:"^6.0.0" spryker/cart-extension:"^3.0.0" spryker/carts-rest-api:"^4.0.0" spryker/checkout:"^5.0.0" spryker/discount:"^8.0.0" spryker/discount-promotion:"^2.0.0" spryker/manual-order-entry-gui:"^0.6.0" spryker/offer:"^0.2.0" spryker/offer-gui:"^0.2.0" spryker/oms:"^9.0.0" spryker/orders-rest-api:"^2.0.0" spryker/persistent-cart:"^2.0.0" spryker/price-cart-connector:"^5.0.0" spryker/price-product:"^3.0.0" spryker/price-product-storage:"^3.0.0" spryker/price-product-volume:"^2.0.0" spryker/price-product-volume-gui:"^2.0.0" spryker/product-availabilities-rest-api:"^2.0.0" spryker/product-bundle:"^5.0.0" spryker/product-discount-connector:"^4.0.0" spryker/product-label-discount-connector:"^2.0.0" spryker/product-management:"^0.17.0" spryker/product-measurement-unit:"^3.0.0" spryker/product-option:"^7.0.0" spryker/product-option-cart-connector:"^6.0.0" spryker/product-packaging-unit:"^2.0.0" spryker/product-packaging-unit-storage:"^3.0.0" spryker/product-quantity:"^2.0.0" spryker/product-quantity-data-import:"^2.0.0" spryker/product-quantity-storage:"^2.0.0" spryker/quick-order:"^2.0.0" spryker/sales:"^9.0.0" spryker/sales-quantity:"^2.0.0" spryker/sales-split:"^4.0.0" spryker/shipment-discount-connector:"^2.0.0" spryker/shopping-list:"^3.0.0" spryker/stock:"^6.0.0" spryker/stock-sales-connector:"^4.0.0" spryker/util-price:"^1.0.0" spryker/util-quantity:"^1.0.0" spryker/wishlist:"^7.0.0" spryker-shop/cart-page:"^2.0.0" spryker-shop/customer-reorder-widget:"^5.0.0" spryker-shop/discount-promotion-widget:"^2.0.0" spryker-shop/product-detail-page:"^2.0.0" spryker-shop/product-measurement-unit-widget:"^0.7.0" spryker-shop/product-packaging-unit-widget:"^0.3.0" spryker-shop/product-search-widget:"^2.0.0" spryker-shop/quick-order-page:"^3.0.0" spryker-shop/shopping-list-page:"^0.7.0" spryker-shop/shopping-list-widget:"^0.5.0" --update-with-dependencies
  1. Run database migration:
console propel:install
console transfer:generate
  1. Manually upgrade the following modules:
  • ProductQuantityStorage
  • ShoppingListWidget

You can find the affected modules of the float stock update in the following list.

Affected modules
OPERATOR OPERATOR FOR PLAIN QUERY MIGRATION GUIDE
spryker/availability 7.0.0 Upgrade the Availability module
spryker/availability-cart-connector 5.0.0 Upgrade the AvailabilityCartConnector module
spryker/availability-gui 4.0.0 Upgrade the AvailabilityGui module
spryker/availability-offer-connector 2.0.0 Upgrade the AvailabilityOfferConnector module
spryker/cart 6.0.0 Upgrade the Cart module
spryker/cart-extension 3.0.0 Upgrade the CartExtension module
spryker/carts-rest-api 4.0.0 Upgrade the CartsRestApi module
spryker/checkout 5.0.0 Upgrade the Checkout module
spryker/discount 8.0.0 Upgrade the Discount module
spryker/discount-promotion 2.0.0 Upgrade the DiscountPromotion module
spryker/manual-order-entry-gui 0.6.0 Migration Guide - ManualOrderEntryGui
spryker/offer 0.2.0 Upgrade the Offer module
spryker/offer-gui 0.2.0 Upgrade the OfferGui module
spryker/oms 9.0.0 Upgrade the Oms module
spryker/orders-rest-api 2.0.0 Upgrade the OrdersRestApi module
spryker/persistent-cart 2.0.0 Migration Guide - PersistentCart
spryker/price-cart-connector 5.0.0 Upgrade the PriceCartConnector module
spryker/price-product 3.0.0 Upgrade the PriceProduct module
spryker/price-product-storage 3.0.0 Upgrade the PriceProductStorage module
spryker/price-product-volume 2.0.0 Upgrade the PriceProductVolume module
spryker/price-product-volume-gui 2.0.0 Upgrade the PriceProductVolumeGui module
spryker/product-availabilities-rest-api 2.0.0 MUpgrade the ProductAvailabilitiesRestApi module
spryker/product-bundle 5.0.0 Upgrade the ProductBundle module
spryker/product-discount-connector 4.0.0 Upgrade the ProductDiscountConnector module
spryker/product-label-discount-connector 2.0.0 Upgrade the ProductLabelDiscountConnector module
spryker/product-management 0.17.0 Upgrade the ProductManagement module
spryker/product-measurement-unit 3.0.0 Upgrade the ProductMeasurementUnit module
spryker/product-option 7.0.0 Upgrade the ProductOption module
spryker/product-option-cart-connector 6.0.0 Upgrade the ProductOptionCartConnector module
spryker/product-packaging-unit 2.0.0 Upgrade the ProductPackagingUnit module
spryker/product-packaging-unit-storage 3.0.0 Upgrade the ProductPackagingUnitStorage module
spryker/product-quantity 2.0.0 Upgrade the ProductQuantity module
spryker/product-quantity-data-import 2.0.0 Upgrade the ProductQuantityDataImport module
spryker/product-quantity-storage 2.0.0 Upgrade the ProductQuantityStorage module
spryker/quick-order 2.0.0 Upgrade the QuickOrder module
spryker/sales 9.0.0 Upgrade the Sales module
spryker/sales-quantity 2.0.0 Upgrade the SalesQuantity module
spryker/sales-split 4.0.0 Upgrade the SalesSplit module
spryker/shipment-discount-connector 2.0.0 Upgrade the ShipmentDiscountConnector module
spryker/shopping-list 3.0.0 Migration Guide - ShoppingList
spryker/stock 6.0.0 Upgrade the Stock module
spryker/stock-sales-connector 4.0.0
spryker/wishlist 7.0.0 Upgrade the WishList module
spryker-shop/cart-page 2.0.0 Upgrade the CartPage module
spryker-shop/customer-reorder-widget 5.0.0 Upgrade the CustomerReorderWidget module
spryker-shop/discount-promotion-widget 2.0.0 Upgrade the DiscountPromotionWidget module
spryker-shop/product-detail-page 2.0.0 Upgrade the ProductDetailPage module
spryker-shop/product-measurement-unit-widget 0.7.0 Upgrade the ProductMeasurementUnit moduleWidget
spryker-shop/product-packaging-unit-widget 0.3.0 Upgrade the ProductPackagingUnitWidget module
spryker-shop/product-search-widget 2.0.0 Upgrade the ProductSearchWidget module
spryker-shop/quick-order-page 3.0.0 Upgrade the QuickOrderPage module
spryker-shop/shopping-list-page 0.7.0 Migration Guide - ShoppingListPage
spryker-shop/shopping-list-widget 0.5.0 Upgrade the ShoppingListWidget module