Changed "list of assertions" link to point to phpunit version 12.0.
Tested on core 10.4.1 with views_data_export 8.x-1.5 using merge request .diff in patches section of composer managed site. The Merge request applied cleanly and I now see 4 options for "Redirect to" under "Redirect Settings".
Active display
Other display
Custom path
Front page
Active display does keep you on the same url once batch completes.
Other display and Custom path seem to function as before.
Front page does indeed redirect you back to the front page of site.
patch #9 wouldn't apply for me for any version of the module. New patch for 2.0.0-alpha2 uploaded.
More information. I've created drupalpods of multiple releases of this module. The issue with reindexing seems to have shown up in release 1.0.0-beta3. This looks like the release that moved away from using the "elasticsearch/elasticsearch": "^8" library. In the \src\Plugin\search_api\backend\ElasticEnterpriseSearchBackend.php, it seems to be using $client = $this->getEnterpriseClient(); as opposed to $client = $this->getClient();
Here are the errors from the logs when I try to re-index items:
Type search_api
Date Friday, November 15, 2024 - 11:17
User 56926@gmail.com
Location https://dbd2c379-dab6-496b-9023-c7cf81c727fa.web.ahdev.cloud/batch?_format=json&id=64672&op=do
Referrer https://dbd2c379-dab6-496b-9023-c7cf81c727fa.web.ahdev.cloud/batch?id=64672&op=start
Message Drupal\search_api\SearchApiException while trying to index items on index ElasticSearch: Could not index items on index 'ElasticSearch' because pending server tasks could not be executed. in Drupal\search_api\Entity\Server->indexItems() (line 353 of /home/ide/project/docroot/modules/contrib/search_api/src/Entity/Server.php)
Severity Error
Hostname 10.24.113.153
Operations
Backtrace
#0 /home/ide/project/docroot/modules/contrib/search_api/src/Entity/Index.php(1006): Drupal\search_api\Entity\Server->indexItems()
#1 /home/ide/project/docroot/modules/contrib/search_api/src/Entity/Index.php(935): Drupal\search_api\Entity\Index->indexSpecificItems()
#2 /home/ide/project/docroot/modules/contrib/search_api/src/IndexBatchHelper.php(160): Drupal\search_api\Entity\Index->indexItems()
#3 [internal function]: Drupal\search_api\IndexBatchHelper::process()
#4 /home/ide/project/docroot/core/includes/batch.inc(296): call_user_func_array()
#5 /home/ide/project/docroot/core/includes/batch.inc(138): _batch_process()
#6 /home/ide/project/docroot/core/includes/batch.inc(94): _batch_do()
#7 /home/ide/project/docroot/core/modules/system/src/Controller/BatchController.php(52): _batch_page()
#8 [internal function]: Drupal\system\Controller\BatchController->batchPage()
#9 /home/ide/project/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#10 /home/ide/project/docroot/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#11 /home/ide/project/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#12 /home/ide/project/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#13 /home/ide/project/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#14 /home/ide/project/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#15 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#16 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#17 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#18 /home/ide/project/docroot/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#19 /home/ide/project/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#20 /home/ide/project/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#21 /home/ide/project/docroot/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle()
#22 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#23 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#24 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#25 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#26 /home/ide/project/docroot/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#27 /home/ide/project/docroot/index.php(19): Drupal\Core\DrupalKernel->handle()
#28 {main}
Type search_api
Date Friday, November 15, 2024 - 11:17
User 56926@gmail.com
Location https://dbd2c379-dab6-496b-9023-c7cf81c727fa.web.ahdev.cloud/batch?_format=json&id=64672&op=do
Referrer https://dbd2c379-dab6-496b-9023-c7cf81c727fa.web.ahdev.cloud/batch?id=64672&op=start
Message Drupal\search_api\SearchApiException: 400 Bad Request in Drupal\centarro_search\Plugin\search_api\backend\ElasticEnterpriseSearchBackend->deleteItems() (line 149 of /home/ide/project/docroot/modules/contrib/centarro_search/src/Plugin/search_api/backend/ElasticEnterpriseSearchBackend.php).
Severity Error
Hostname 10.24.113.153
Operations
Backtrace
#0 /home/ide/project/docroot/modules/contrib/search_api/src/Task/ServerTaskManager.php(167): Drupal\centarro_search\Plugin\search_api\backend\ElasticEnterpriseSearchBackend->deleteItems()
#1 /home/ide/project/docroot/modules/contrib/search_api/src/Task/ServerTaskManager.php(114): Drupal\search_api\Task\ServerTaskManager->executeTask()
#2 [internal function]: Drupal\search_api\Task\ServerTaskManager->processEvent()
#3 /home/ide/project/docroot/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func()
#4 /home/ide/project/docroot/modules/contrib/search_api/src/Task/TaskManager.php(212): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch()
#5 /home/ide/project/docroot/modules/contrib/search_api/src/Task/TaskManager.php(264): Drupal\search_api\Task\TaskManager->executeSpecificTask()
#6 /home/ide/project/docroot/modules/contrib/search_api/src/Task/ServerTaskManager.php(94): Drupal\search_api\Task\TaskManager->executeAllTasks()
#7 /home/ide/project/docroot/modules/contrib/search_api/src/Entity/Server.php(349): Drupal\search_api\Task\ServerTaskManager->execute()
#8 /home/ide/project/docroot/modules/contrib/search_api/src/Entity/Index.php(1006): Drupal\search_api\Entity\Server->indexItems()
#9 /home/ide/project/docroot/modules/contrib/search_api/src/Entity/Index.php(935): Drupal\search_api\Entity\Index->indexSpecificItems()
#10 /home/ide/project/docroot/modules/contrib/search_api/src/IndexBatchHelper.php(160): Drupal\search_api\Entity\Index->indexItems()
#11 [internal function]: Drupal\search_api\IndexBatchHelper::process()
#12 /home/ide/project/docroot/core/includes/batch.inc(296): call_user_func_array()
#13 /home/ide/project/docroot/core/includes/batch.inc(138): _batch_process()
#14 /home/ide/project/docroot/core/includes/batch.inc(94): _batch_do()
#15 /home/ide/project/docroot/core/modules/system/src/Controller/BatchController.php(52): _batch_page()
#16 [internal function]: Drupal\system\Controller\BatchController->batchPage()
#17 /home/ide/project/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
#18 /home/ide/project/docroot/core/lib/Drupal/Core/Render/Renderer.php(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#19 /home/ide/project/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#20 /home/ide/project/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#21 /home/ide/project/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#22 /home/ide/project/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#23 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#24 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
#25 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#26 /home/ide/project/docroot/core/modules/big_pipe/src/StackMiddleware/ContentLength.php(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#27 /home/ide/project/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#28 /home/ide/project/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
#29 /home/ide/project/docroot/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle()
#30 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle()
#31 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#32 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#33 /home/ide/project/docroot/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#34 /home/ide/project/docroot/core/lib/Drupal/Core/DrupalKernel.php(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#35 /home/ide/project/docroot/index.php(19): Drupal\Core\DrupalKernel->handle()
#36 {main}
Additionally, here's the complete error I receive after clicking the 'Execute pending tasks' button:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /batch?id=64671&op=do_nojs&op=do
StatusText: 500 Service unavailable (with message)
ResponseText: The website encountered an unexpected error. Try again later.Drupal\search_api\SearchApiException: 400 Bad Request in Drupal\centarro_search\Plugin\search_api\backend\ElasticEnterpriseSearchBackend->deleteItems() (line 149 of modules/contrib/centarro_search/src/Plugin/search_api/backend/ElasticEnterpriseSearchBackend.php). Drupal\search_api\Task\ServerTaskManager->executeTask() (Line: 114)
Drupal\search_api\Task\ServerTaskManager->processEvent()
call_user_func() (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 212)
Drupal\search_api\Task\TaskManager->executeSpecificTask() (Line: 362)
Drupal\search_api\Task\TaskManager->processBatch()
call_user_func_array() (Line: 296)
_batch_process() (Line: 138)
_batch_do() (Line: 94)
_batch_page() (Line: 52)
Drupal\system\Controller\BatchController->batchPage()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 638)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 50)
Drupal\ban\BanMiddleware->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 741)
Drupal\Core\DrupalKernel->handle() (Line: 19)
I have made the small change as I understood it. Please let me know if it needs any updates.
In this note (https://git.drupalcode.org/project/drupal/-/merge_requests/8011#note_316513), if I understand correctly, @finnsky asks for the margin-block-end style to be changed to padding-bottom and added to the .admin-toolbar__footer rule, as opposed to the .admin-toolbar__footer > .toolbar-block:last-of-type where it currently resides.
If this is all true, the spacing would occur after the collapse button (.admin-toolbar__expand-button) rather than between the 'Help' and links as it does now. So should I add the padding to the bottom of the .admin-toolbar__footer or to the link?
Working on this as a novice to become more familiar with contributing. Thank you for any feedback/advise/criticisms.
rsnyd → changed the visibility of the branch 3445993-provide-a-navigationlinkblock to active.
Working on this.
@sharif.tanveer or anyone else finding this,
Try to follow this article: Reading and Writing Google Sheets in PHP.
Also, here's is my custom Drush command that only reads from a Google sheet:
namespace Drupal\custom_module\Drush\Commands;
use Drupal\commerce_stock_local\Event\LocalStockTransactionEvent;
use Drupal\commerce_stock_local\Event\LocalStockTransactionEvents;
use Drupal\commerce_stock\StockTransactionsInterface;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\File\FileSystemInterface;
use Drush\Attributes as CLI;
use Drush\Commands\DrushCommands;
use GuzzleHttp\ClientInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Drush commands for Google.
*/
class GoogleCommands extends DrushCommands {
/**
* Name for module's configuration object.
*/
const SETTINGS = 'custom_module.settings';
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManager
*/
protected $entityTypeManager;
/**
* The Guzzle client for http requests.
*
* @var \GuzzleHttp\ClientInterface
*/
protected $httpClient;
/**
* Default database connection.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* The file system service.
*/
protected FileSystemInterface $fileSystem;
/**
* TaxjarCommands constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
* The entity_type.manager service.
* @param \GuzzleHttp\ClientInterface $http_client
* The module_handler service.
* @param \Drupal\Core\Database\Connection $connection
* Default database connection.
* @param \Drupal\Core\File\FileUrlGenerator $file_url_generator
* For getting the url of images.
*/
public function __construct(EntityTypeManager $entity_type_manager, ClientInterface $http_client, Connection $connection, FileSystemInterface $fileSystem) {
parent::__construct();
$this->entityTypeManager = $entity_type_manager;
$this->httpClient = $http_client;
$this->connection = $connection;
$this->fileSystem = $fileSystem;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity_type.manager'),
$container->get('http_client'),
$container->get('database'),
$container->get('file_system'),
);
}
/**
* Sync inventory with a specific Google Sheet.
*
* @validate-module-enabled commerce_stock_product
*
* @command google:syncInventory
* @aliases google:syncInventory
*/
#[CLI\Command(name: 'google:syncInventory', aliases: ['google-syncInventory'])]
#[CLI\Usage(name: 'google:syncInventory google-syncInventory', description: 'Sync inventory for the last 1 day')]
public function syncInventory() {
$messages = [];
// configure the Google Client
//https://www.nidup.io/blog/manipulate-google-sheets-in-php-with-api
$client = new \Google_Client();
$client->setApplicationName('Google Sheets API');
$client->setScopes([\Google_Service_Sheets::SPREADSHEETS]);
$client->setAccessType('offline');
$config = \Drupal::config(self::SETTINGS);
$fid = $config->get('credentials_file')[0];
$file = $this->entityTypeManager->getStorage('file')->load($fid);
$credentials_path = $this->fileSystem->realpath('private://' . $file->getFilename());
$client->setAuthConfig($credentials_path);
// configure the Sheets Service
$service = new \Google_Service_Sheets($client);
$spreadsheetId = 'qwerttyik57684-0easdfsadfasdfsdd3sphUs0bLx8';
$spreadsheet_url = $config->get('url');
$path = parse_url($spreadsheet_url)['path'];
$parts = explode('/', $path);
foreach ($parts as $index => $part) {
if ($part == 'd') {
$spreadsheetId = $parts[$index + 1];
break;
}
}
// get all the rows of a sheet
$range = 'Inventory Check!A:J'; // here we use the name of the Sheet to get all the rows
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();
$stockCheckerService = \Drupal::service('commerce_stock_product.product_local_stock_checker');
$eventDispatcher = \Drupal::service('event_dispatcher');
$database = \Drupal::database();
$config_factory = \Drupal::service('config.factory');
$stock_config = $config_factory->get('commerce_stock_local.transactions');
// Remove the top hidden row
array_shift($values);
// Remove the "Orders counted to:" row
array_shift($values);
$headers = reset($values);
$headers = array_map('strtolower', str_replace(' ', '', $headers));
foreach ($values as $row) {
$row = array_pad($row, count($headers), '');
$row = array_combine($headers, $row);
if (!array_key_exists('sku', $row)) {
continue;
}
$products = $this->entityTypeManager->getStorage('commerce_product')->loadByProperties([
'status' => TRUE,
'field_sku_root' => $row['sku'],
]);
/** @var \Drupal\commerce_product\Entity\ProductInterface $product */
$product = reset($products);
if (!$product) {
continue;
}
if ($product->hasField('field_stock_level')) {
$stock_level = $product->get('field_stock_level')->first();
($stock_level)
? $available_stock = $stock_level->get('available_stock')->getValue()
: $available_stock = 0;
} else
$available_stock = 0;
if ((array_key_exists('availableinventory', $row)) && (is_numeric($row['availableinventory']))) {
$metadata = [];
$location_id = 1;
// Get optional fields.
$related_tid = $metadata['related_tid'] ?? NULL;
$related_oid = $metadata['related_oid'] ?? NULL;
$related_uid = $metadata['related_uid'] ?? NULL;
$data = $metadata['data'] ?? NULL;
// Create a transaction record.
$field_values = [
'entity_id' => $product->id(),
'entity_type' => $product->getEntityTypeId(),
'qty' => $row['availableinventory'],
'location_id' => $location_id,
'location_zone' => '',
'unit_cost' => 0,
'currency_code' => 'USD',
'transaction_time' => time(),
'transaction_type_id' => StockTransactionsInterface::STOCK_IN,
'related_tid' => $related_tid,
'related_oid' => $related_oid,
'related_uid' => $related_uid,
'data' => serialize($data),
];
$event = new LocalStockTransactionEvent($this->entityTypeManager, $field_values);
// Since we basically reset the inventory every day, delete all previous transactions
$database->delete('commerce_stock_transaction')
->condition('location_id', $location_id)
->condition('entity_id', $product->id())
->condition('entity_type', $product->getEntityTypeId())
->execute();
// Create a STOCK_IN transaction
$eventDispatcher->dispatch($event, LocalStockTransactionEvents::LOCAL_STOCK_TRANSACTION_CREATE);
$insert = $database->insert('commerce_stock_transaction')
->fields(array_keys($field_values))
->values(array_values($field_values))->execute();
$eventDispatcher->dispatch($event, LocalStockTransactionEvents::LOCAL_STOCK_TRANSACTION_INSERT);
// Update the field_stock_level attached to the product
$existing = $database->select('commerce_product__field_stock_level', 'fsl')
->fields('fsl')
->condition('entity_id', $product->id())
->execute()->fetch();
if ($existing) {
$database->update('commerce_product__field_stock_level')
->fields([
'field_stock_level_value' => $row['availableinventory'],
])
->condition('entity_id', $product->id(), '=')
->execute();
} else {
$database->insert('commerce_product__field_stock_level')
->fields([
'bundle',
'deleted',
'entity_id',
'revision_id',
'langcode',
'delta',
'field_stock_level_value',
])
->values([
$product->bundle(),
0,
$product->id(),
$product->id(),
'en',
0,
$row['availableinventory'],
])
->execute();
}
// Find out if we have real-time aggregation turned on.
$transactions_aggregation_mode = $stock_config->get('transactions_aggregation_mode');
if ($transactions_aggregation_mode == 'real-time') {
// Aggregate if we do.
$locations = $this->entityTypeManager->getStorage('commerce_stock_location')->loadEnabled($product->getDefaultVariation());
foreach ($locations as $location) {
// updateLocationStockLevel()
$current_level = $stockCheckerService->getLocationStockLevel($location->getId(), $product->getDefaultVariation());
$last_update = $current_level['last_transaction'];
$latest_txn = $stockCheckerService->getLocationStockTransactionLatest($location->getId(), $product->getDefaultVariation());
$latest_sum = $stockCheckerService->getLocationStockTransactionSum($location->getId(), $product->getDefaultVariation(), $last_update, $latest_txn);
$new_level = $row['availableinventory'];
// setLocationStockLevel()
$existing = $database->select('commerce_stock_location_level', 'll')
->fields('ll')
->condition('location_id', $location->getId())
->condition('entity_id', $product->id())
->condition('entity_type', $product->getEntityTypeId())
->execute()->fetch();
if ($existing) {
$database->update('commerce_stock_location_level')
->fields([
'qty' => $new_level,
'last_transaction_id' => $latest_txn,
])
->condition('location_id', $location->getId(), '=')
->condition('entity_id', $product->id(), '=')
->condition('entity_type', $product->getEntityTypeId())
->execute();
} else {
$database->insert('commerce_stock_location_level')
->fields([
'location_id',
'entity_id',
'entity_type',
'qty',
'last_transaction_id',
])
->values([
$location->getId(),
$product->id(),
$product->getEntityTypeId(),
$new_level,
$latest_txn,
])
->execute();
}
}
}
$product->save();
}
$messages[] = $product->getTitle() . ' Inventory Updated. (' . $available_stock . ' to ' . $row['availableinventory'] . ')';
}
\Drupal::logger('custom_module')->info(implode("<br/>", $messages));
}
}
@eit2103,
I'm on 10.2.2 and currently using commerce_giftcard in production. Although, I will say, we are currently having issues that I am investigating, but this setup was working until recently.
From my composer:
"drupal/commerce_giftcard": "dev-3295499-drupal-10-compatibility",
patches:
"drupal/commerce_giftcard": {
"3180964-5: Theme hook commerce_giftcard_redemption_form not found": "
https://www.drupal.org/files/issues/2021-12-13/theme_hook_commerce_giftc... →
",
"3184543: Gift card should generate standard commerce events": "
https://www.drupal.org/files/issues/2020-11-24/commerce_giftcard-modify-... →
"
},
@a.dmitriiev/@UriDrupal,
I've followed the screen captures below, installed the fields on the product type, set the configuration for my product variation type, and I've ensured the patch was installed. The field shows on the product edit form, but will not save the value entered. After debugging, I found this error:
Error message
Warning: Undefined variable $multiplier1 in Drupal\commerce_stock_product\ProductLocalStockUpdater->createTransaction() (line 69 of modules/custom/commerce_stock_product/src/ProductLocalStockUpdater.php).
Drupal\commerce_stock_product\ProductLocalStockUpdater->createTransaction(Object, '1', '', 2, 0, NULL, 1, Array) (Line: 125)
Drupal\commerce_stock\StockServiceManager->createTransaction(Object, '1', '', 2, 0, NULL, 1, Array) (Line: 182)
Drupal\commerce_stock_field\Plugin\Field\FieldType\StockLevel->createTransaction(Object, Array) (Line: 42)
Drupal\commerce_stock_product\Plugin\Field\FieldType\StockLevel->postSave(1)
call_user_func_array(Array, Array) (Line: 233)
Drupal\Core\Field\FieldItemList->delegateMethod('postSave', 1) (Line: 198)
Drupal\Core\Field\FieldItemList->postSave(1)
call_user_func_array(Array, Array) (Line: 938)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldMethod('postSave', Object, 1) (Line: 984)
Drupal\Core\Entity\ContentEntityStorageBase->invokeFieldPostSave(Object, 1) (Line: 896)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('update', Object) (Line: 56)
Drupal\commerce\CommerceContentEntityStorage->invokeHook('update', Object) (Line: 564)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, 1) (Line: 781)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, 1) (Line: 489)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 352)
Drupal\Core\Entity\EntityBase->save() (Line: 237)
Drupal\commerce_product\Form\ProductForm->save(Array, Object)
Removing the $multiplier variable for now allows me to save the value. I will continue testing. @UriDrupal, does this also help you to get it working?
@a.dmitriiev,
Thank you for the patch and module. I'm working on this same challenge. I've updated commerce_stock with the patch from #16, downloaded, unzipped and installed your commerce_stock_product from #17. I've added the two reusable fields to my default product bundle and set the field widget to "Simple stock transaction for products". Finally, I've configured commerce_stock here: /admin/commerce/config/stock/settings to use the "Product local stock" service for both the default service and the Product Variation.
The fields show on my product edit form, but I'm unable to change the value of the stock level. No errors, but if I enter 5 into the field and save, Current stock level: remains at 0. I've also tried adding a stock level field to the product variation type for the default product bundle, but that doesn't seem to work either. Can you please suggest what I may be doing wrong?
I am experiencing the same thing. I've played around with the filtering as suggested by @BenStallings and while removing certain filters does finally provide some results in the downloadable file, I find that no matter what filters I use, if the total number results is > approx. 150 rows, the Batch method returns a nearly empty file. I am also using the views_data_export_phpspreadsheet module and my file DOES have the column titles, but that is all. Standard mode has the same limitations for me, so perhaps the issue is not in the mode selection?
@Maintainers,
Any chance we could get someone to review this fix?
Thanks for the module!!
@catch,
You were reporter for both: (
https://www.drupal.org/node/3383449 →
and
https://www.drupal.org/node/3377570 →
)
Do you think either of the those two 'fixed' issues are related to this?
@catch,
Thank you. This is from our non-production site. All future comments will not contain the twig debug comments.
I am able to consistently reproduce this, which seems to be one of the big problems on this issue. I'm happy to follow guidance to make changes, but unable to troubleshoot myself.
Hi all,
We've recently upgraded to 10.2.0 and we're now experiencing this issue with our search form block. The issue does seem to go away when I am not logged in, but when i am logged in, the block only shows about 20% of the time.
When the block is missing, it's HTML is replaced with the following:
<span data-big-pipe-placeholder-id="callback=Drupal%5Cblock%5CBlockViewBuilder%3A%3AlazyBuilder&args%5B0%5D=spicy_nextopiasearchblock&args%5B1%5D=full&args%5B2%5D&token=jS-7dOtSNj9P4Sz8UWKNnZ1REPBxwc_mLbSlHVEpb64">
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'big_pipe_interface_preview' -->
<!-- FILE NAME SUGGESTIONS:
* big-pipe-interface-preview--block--full.html.twig
* big-pipe-interface-preview--block--spicy-nextopiasearchblock.html.twig
* big-pipe-interface-preview--block.html.twig
x big-pipe-interface-preview.html.twig
-->
<!-- BEGIN OUTPUT from 'core/modules/big_pipe/templates/big-pipe-interface-preview.html.twig' -->
<!-- END OUTPUT from 'core/modules/big_pipe/templates/big-pipe-interface-preview.html.twig' -->
</span>
I am currently using Chrome 120.0.6099.110
To all who may happen upon my previous comment, I've received a response on Drupal Slack from one of the project maintainers pointing me to the code from the Visitors Voice project here:
https://www.drupal.org/project/visitorsvoice →
This is a D7 project, but apparently contains the result modification logic I am looking for. Additionally, a final comment:
"Basically, though, you’ll always need to index extra fields if you want to modify the search results in a seamless way (i.e., without messing up paging, sorting, facet counts, etc.)."
I will post my results once I'm able to successfully implement the addition of items to my ResultSet.
Thank you for the fantastic module! I realize this issue is closed, but there is surprisingly little to be found on this, so I thought I would post my question in case others stumble across this post.
When adding items to a ResultSet in this way, find find two issues. For me, I'm combining content nodes and commerce product entities in my search results. When using a particular search term, there are 130 matches. Since my page size is set to 48 items per page, these 130 are broken into 3 pages. I've tried using both the SearchApiSolrEvents::POST_EXTRACT_RESULTS and search_api.processing_results events and I have the same results with each.
Problem #1: The items are added to each page of the results. Meaning, if I add an additional 3 items to the ResultSet in the EvenSubscriber, the first page has 51 items, the second page has 51 items, and the third page has 37 items. The last 3 items of each page are my additions. How might I add these 3 items to the initial ResultSet of 130 items so they are only shown on one page?
Problem #2: The items are added to the end of the list of items for any page. I've used the $new_item->setScore(51); to manually set the score higher than all other items, but my additions remain at the bottom of the list. How do I modify the relevancy for these items so they move to the top of the ResultSet?
Changes made to origin/3341110-toolbar-is-colored branch that fix the disabling of the toolbar integration.
Same issue. Similar problem here?
https://www.drupal.org/project/environment_indicator/issues/3077679 →
@rubenjara,
Ok, I understand what you're saying, but I don't see that line of code in this fork/branch. (https://git.drupalcode.org/issue/commerce_giftcard-3295499/-/blob/329549...)
@everyone,
This issue is ready for review. Can anyone from the community review and test these changes?
@rubenjara,
Are you sure you have the correct permissions set?
+1 for having a new release with D10 supported!
Yes, please clarify. Thank you.
My apologies about the commit message format. I will fix in the next.
@Berdir Thank you for your help. Too many patches and apparently merge requests are the way to go these days. I've made the same changes and left the tests intact. Happy to keep working on this if there are still outstanding issues.
Here's a patch to just get me to D10. I've removed the tests for now.
Replacing the accessChecks within the if statements.
Ok,
So after at least getting the patch to apply, I'm at a loss. It seems like I'm getting the same errors as @Berdir. Happy to continue to work on this but I need some guidance. Thank you in advance.
I'm new to patching/contributing, but here's my attempt. Any feedback is MORE than welcome.
@jsacksick,
So sorry, I'm not sure how that happened.
Thank you again.
@jsacksick,
Ok, my changes include the following:
- core_version_requirement in info.yml to be ^9.1 || ^10
- use statement in ShipStationOrderExportedEvent to use bridge class
- Type hints in ShipStation to use \Symfony\Contracts\EventDispatcher\EventDispatcherInterface (from your link, NOTE: I did not change the use statement to match since the link only specifically mentions the type hints and "Since Symfony 4.3, Symfony\Component\EventDispatcher\EventDispatcherInterface extends Symfony\Contracts\EventDispatcher\EventDispatcherInterface")
- I have created the patch from the commerce_shipstation cloned repository folder this time
- I have not touched the coding standards or the addressed the dependency injection issues since I'm just trying to get my first patch accepted and I figure simpler is better. Happy to address these in another issue, but I see that @c_archer has already volunteered
I hope this one is correct. Thank you for taking the time to help me.
@jsacksick,
Thank you for the helpful feedback. So I've changed the .info.yml file to drop the D8 compatability. ShipStationOrderExportedEvent now uses Drupal\Component\EventDispatcher\Event.
These two changes are included in the patch.
As for the tests, there is really only one that ShipStationKernelTestBase is the only class that contains real tests, i.e. not just stubs/function signatures. This test only references commerce_order, commerce_shipping, commerce_product and profile packages, so I don't think there's anything to do to get it to run on D10. The root composer.json, however, requires "drupal/commerce": "^2.17" and "drupal/commerce_shipping": "^2.1". Do these versions need to be updated to "drupal/commerce": "^2.36" and/or "drupal/commerce_shipping": "^2.6"?
Thank you for the help.
https://www.drupal.org/project/commerce_giftcard/issues/3295499 📌 Drupal 10 compatibility and fixing tests with latest commerce RTBC
Attempting a patch based on upgrade_status suggestions.
@J.,
Is this for 8.x-2.x-dev? I'm getting a .rej for the patch in #6.
--- src/EventTrackerService.php
+++ src/EventTrackerService.php
@@ -238,7 +238,7 @@ class EventTrackerService {
// Throw an event to add possible checkout step options by event listeners.
$event = new TrackCheckoutStepEvent($step_index, $order);
- $this->eventDispatcher->dispatch(EnhancedEcommerceEvents::TRACK_CHECKOUT_STEP, $event);
+ $this->eventDispatcher->dispatch($event, EnhancedEcommerceEvents::TRACK_CHECKOUT_STEP);
}
/**
rsnyd@yahoo.com → created an issue.
rsnyd@yahoo.com → created an issue.
@PrabuEla and @jsacksick, thank you both for the guidance. I've made the access checks each ->acessCheck(FALSE). New patch uploaded.
One more try.
My first patch which includes some small changes identified by the upgrade_status module. Feedback is more than welcome.