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
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 Migration Guide - Discount
spryker/discount-promotion 2.0.0 Migration Guide - DiscountPromotion
spryker/manual-order-entry-gui 0.6.0 Migration Guide - ManualOrderEntryGui
spryker/offer 0.2.0 Migration Guide - Offer
spryker/offer-gui 0.2.0 Migration Guide - OfferGui
spryker/oms 9.0.0 Migration Guide - Oms
spryker/orders-rest-api 2.0.0 Migration Guide - OrdersRestApi
spryker/persistent-cart 2.0.0 Migration Guide - PersistentCart
spryker/price-cart-connector 5.0.0 Migration Guide - PriceCartConnector
spryker/price-product 3.0.0 Migration Guide - PriceProduct
spryker/price-product-storage 3.0.0 Migration Guide - PriceProductStorage
spryker/price-product-volume 2.0.0 Migration Guide - PriceProductVolume
spryker/price-product-volume-gui 2.0.0 Migration Guide - PriceProductVolumeGui
spryker/product-availabilities-rest-api 2.0.0 Migration Guide - ProductAvailabilitiesRestApi
spryker/product-bundle 5.0.0 Migration Guide - ProductBundle
spryker/product-discount-connector 4.0.0 Migration Guide - ProductDiscountConnector
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 Migration Guide - ProductMeasurementUnit
spryker/product-option 7.0.0 Migration Guide - ProductOption
spryker/product-option-cart-connector 6.0.0 Upgrade the ProductOptionCartConnector module
spryker/product-packaging-unit 2.0.0 Migration Guide - ProductPackagingUnit
spryker/product-packaging-unit-storage 3.0.0 Migration Guide - ProductPackagingUnitStorage
spryker/product-quantity 2.0.0 Migration Guide - ProductQuantity
spryker/product-quantity-data-import 2.0.0 Migration Guide - ProductQuantityDataImport
spryker/product-quantity-storage 2.0.0 Migration Guide - ProductQuantityStorage
spryker/quick-order 2.0.0 Migration Guide - QuickOrder
spryker/sales 9.0.0 Migration Guide - Sales
spryker/sales-quantity 2.0.0 Migration Guide - SalesQuantity
spryker/sales-split 4.0.0 Migration Guide - SalesSplit
spryker/shipment-discount-connector 2.0.0 Migration Guide - ShipmentDiscountConnector
spryker/shopping-list 3.0.0 Migration Guide - ShoppingList
spryker/stock 6.0.0 Migration Guide - Stock
spryker/stock-sales-connector 4.0.0
spryker/wishlist 7.0.0 Migration Guide - WishList
spryker-shop/cart-page 2.0.0 Upgrade the CartPage module
spryker-shop/customer-reorder-widget 5.0.0 Migration Guide - CustomerReorderWidget
spryker-shop/discount-promotion-widget 2.0.0 Migration Guide - DiscountPromotionWidget
spryker-shop/product-detail-page 2.0.0 Migration Guide - ProductDetailPage
spryker-shop/product-measurement-unit-widget 0.7.0 Migration Guide - ProductMeasurementUnitWidget
spryker-shop/product-packaging-unit-widget 0.3.0 Migration Guide - ProductPackagingUnitWidget
spryker-shop/product-search-widget 2.0.0 Migration Guide - ProductSearchWidget
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 Migration Guide - ShoppingListWidget