- πΊπΈUnited States mayjorb
This also worked for me, using the yml script in comment #11, and the patch in comment #9
Drupal 9.5.3, Commerce Stock 8.x-1.
As a site owner migrating from Drupal 7, I need a way to set the stock levels when products are imported. Ideally, we'd have a migration plugin for this, but in the interim, I've created a Drush command to handle this with the following code:
use Drupal\commerce_product\Entity\ProductVariation;
use Drupal\commerce_stock\StockTransactionsInterface;
function drush_my_migrate_add_commerce_stock() {
$stockServiceManager = \Drupal::service('commerce_stock.service_manager');
$variations = \Drupal::entityQuery('commerce_product_variation')
->condition('sku', 'MYSKU')
->execute();
$variation = ProductVariation::load(reset($variations));
$stockServiceManager->createTransaction($variation, 1, '', 10, NULL, NULL, StockTransactionsInterface::STOCK_IN, ['data' => []]);
}
Needs review
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
This also worked for me, using the yml script in comment #11, and the patch in comment #9
Drupal 9.5.3, Commerce Stock 8.x-1.