On 3/22/2023 at 4:27 PM, daninapoli said:
¿Puedes mostrarme el código que cambiaste? no necesita un módulo personalizado por ahora ...
Aquí creé las dos variables $colorTitle y $colorValue y les asigné los valores correspondientes. Donde 'value' es el color del producto.
public function viewAction(int $orderId, Request $request): Response { try { /** @var OrderForViewing $orderForViewing */ $orderForViewing = $this->getQueryBus()->handle(new GetOrderForViewing($orderId, QuerySorting::DESC)); } catch (OrderException $e) { $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); return $this->redirectToRoute('admin_orders_index'); } $colorTitle = ''; $colorValue = ''; foreach( $orderForViewing->getProducts()->getProducts() as $product ){ $product_order = new \Product($product->getId()); foreach( $product_order->getFrontFeaturesStatic( 1,$product->getId() ) as $feature ){ if( $feature['id_feature'] == 1 ){ $colorTitle = $feature['name']; $colorValue = $feature['value']; } } }
Luego asigno las variables al final de la clase.
return $this->render('@PrestaShop/Admin/Sell/Order/Order/view.html.twig', [ 'showContentHeader' => true, 'enableSidebar' => true, 'orderCurrency' => $orderCurrency, 'meta_title' => $metatitle, 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), 'orderForViewing' => $orderForViewing, 'addOrderCartRuleForm' => $addOrderCartRuleForm->createView(), 'updateOrderStatusForm' => $updateOrderStatusForm->createView(), 'updateOrderStatusActionBarForm' => $updateOrderStatusActionBarForm->createView(), 'addOrderPaymentForm' => $addOrderPaymentForm->createView(), 'changeOrderCurrencyForm' => $changeOrderCurrencyForm->createView(), 'privateNoteForm' => $privateNoteForm ? $privateNoteForm->createView() : null, 'updateOrderShippingForm' => $updateOrderShippingForm->createView(), 'cancelProductForm' => $cancelProductForm->createView(), 'invoiceManagementIsEnabled' => $orderForViewing->isInvoiceManagementIsEnabled(), 'changeOrderAddressForm' => $changeOrderAddressForm ? $changeOrderAddressForm->createView() : null, 'orderMessageForm' => $orderMessageForm->createView(), 'addProductRowForm' => $addProductRowForm->createView(), 'editProductRowForm' => $editProductRowForm->createView(), 'backOfficeOrderButtons' => $backOfficeOrderButtons, 'merchandiseReturnEnabled' => $merchandiseReturnEnabled, 'priceSpecification' => $this->getContextLocale()->getPriceSpecification($orderCurrency->iso_code)->toArray(), 'previousOrderId' => $orderSiblingProvider->getPreviousOrderId($orderId), 'nextOrderId' => $orderSiblingProvider->getNextOrderId($orderId), 'paginationNum' => $paginationNum, 'paginationNumOptions' => $paginationNumOptions, 'isAvailableQuantityDisplayed' => $this->configuration->getBoolean('PS_STOCK_MANAGEMENT'), 'internalNoteForm' => $internalNoteForm->createView(), 'colorTitle' => $colorTitle, 'colorValue' => $colorValue, ]);
Todo esto lo hago en el OrderController.php el cual es parte del core de Prestashop. No debería hacer eso, pero la verdad me ha sido imposible hacer override.
Esto está funcionando perfectamente ahora.