Problem/Motivation
FIX Code, add redirect if not isset product :
commerce_stock/modules/ui/src/Form/StockTransactions2.php
solution 1:
redirect in the form StockTransactions2.StockTransactions2.php
solution 2:
redirect to page 404
class ExampleRedirectSubscriber implements EventSubscriberInterface {
/**
* {@inheritdoc}
*/
public function redirect(GetResponseEvent $event) {
$request = $event->getRequest();
$currentPath = $request->getPathInfo();
if (
'/admin/commerce/config/stock/transactions2' === $currentPath &&
$request->query->has('commerce_product_v_id') &&
!ProductVariation::load((int) $request->query->get('commerce_product_v_id'))
) {
if (!$event->isMasterRequest()) {
return;
}
throw new NotFoundHttpException();
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
KernelEvents::REQUEST => ['redirect', 100]
];
}
}
Issue fork commerce_stock-3241838
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
arvodia commentedComment #4
arvodia commentedComment #5
arvodia commentedComment #6
guy_schneerson commentedThanks @arvodia
I will use your code for sanding back to stock_transactions1 if not found and will add an error message to make it clear.
Comment #8
guy_schneerson commented