Jump to content

Affichage du champ $product.availability_message dans un module


Recommended Posts

Bonjour,

j'ai récemment acheter un module permettant d'effectuer des devis, cependant j'aurai besoin d'afficher le champ {$product.availability_message} dans une colonne "Disponibilité", celle ci n'est pas récupéré par le module en question. Quelqu'un aurait une idée de comment faire pour afficher ce champ ?
J'ai essayé via un @var_dump, cela me retourne NULL

Voir capture d'écran
Merci beaucoup !

Capture d’écran 2021-06-01 114037.jpg

Link to comment
Share on other sites

Salut Maxime,

il faudrait regarder comment le module recupere la variable $product dans le controller front, soit ajouter la donnée dans la requête soit faire une fonction pour y ajouter ce champs et l 'assigner a smarty dans une nouvelle variable, ensuite l'afficher dans le tpl

cdt

Link to comment
Share on other sites

Hello à vous, merci de votre réponse,
Mediacom, ma demande sortait du cadre du "SAV" du coup il m'invitait à prendre contact avec un développeur...
Alexandre, merci du conseil je vais regarde ça et je reviens vers vous rapidement !

Link to comment
Share on other sites

Bonjour,
Du coup j'ai deux fichiers, un controller et un fichier appelé par le controller au debut que vous trouverez en PJ
Dans le controller j'ai cette fonction :

 

  private function processCreateQuotation(Customer $customer, Cart $cart)
    {
        $show_form = true;

        //get customers addresses
        if (!Validate::isLoadedObject($customer)) {
            $addresses = array();
        } else {
            $addresses = $customer->getAddresses($this->context->language->id);
        }

        if (count($addresses) == 0) {
            $this->errors[] = Tools::displayError($this->module->l('You have to save at least one address, before creating your quotation', 'createquotation'));

            $this->context->cookie->__set('opartdevis_no_address', '1');

            if ($this->isSeven) {
                $this->redirectWithNotifications('address');
            }
        }

        if ($cart->nbProducts() == 0) {
            if (Configuration::get('OPARTDEVIS_SIMPLE_FORM')) {
                Tools::redirect(
                    (new Link())->getModuleLink(
                        'opartdevis',
                        'simplequotation',
                        array()
                    )
                );
            }

            $show_form = false;
            $this->context->smarty->assign('isCartEmpty', true);
        }

        $from = (Tools::getIsset('from')) ? Tools::getValue('from') : '';

        if ($this->errors) {
            $show_form = false;
        }

        //search id by cart
        $quotationObj = OpartQuotation::getByCartId($cart->id);

        if (is_object($quotationObj)) {
            $quotationId = $quotationObj->id_opartdevis;
            $quotationName = $quotationObj->name;
        } else {
            $quotationId = null;
            $quotationName = '';
        }

        $summary = $cart->getSummaryDetails();
        $customized_datas = Product::getAllCustomizedDatas($cart->id);

        foreach ($summary['products'] as &$product) {
            if (Product::getTaxCalculationMethod()) {
                $product['standard_price'] = Product::getPriceStatic((int)$product["id_product"], false, $product['id_product_attribute'], 2, null, false, false);
                if (Configuration::get('OPARTDEVIS_REDUC_PERCENT')) {
                    $product['reduction_value'] =
                        round(
                            (
                                ($product['standard_price'] - $product['price'])
                                / $product['standard_price']
                            ) * 100,
                            2
                        );
                } else {
                    $product['reduction_value'] = $product['standard_price'] - $product['price'];
                }

                if ($product['reduction_value'] <= 0) {
                    $product['reduction_value'] = false;
                    $product['standard_price'] = false;
                }
            } else {
                $product['standard_price'] = Product::getPriceStatic((int)$product["id_product"], true, $product['id_product_attribute'], 2, null, false, false);
                if (Configuration::get('OPARTDEVIS_REDUC_PERCENT')) {
                    $product['reduction_value'] =
                        round(
                            (
                                ($product['standard_price'] - $product['price_wt'])
                                / $product['standard_price']
                            ) * 100,
                            2
                        );
                } else {
                    $product['reduction_value'] = $product['standard_price'] - $product['price_wt'];
                }

                if ($product['reduction_value'] <= 0) {
                    $product['reduction_value'] = false;
                    $product['standard_price'] = false;
                }
            }
        }

        if ($customized_datas) {
            foreach ($summary['products'] as &$product_update) {
                $product_id = (isset($product_update['id_product']) ? $product_update['id_product'] : $product_update['product_id']);
                $product_attribute_id = (isset($product_update['id_product_attribute']) ?
                    $product_update['id_product_attribute'] : $product_update['product_attribute_id']);

                if (isset($customized_datas[$product_id][$product_attribute_id])) {
                    $product_update['tax_rate'] = Tax::getProductTaxRate($product_id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
                }
            }

            Product::addCustomizationPrice($summary['products'], $customized_datas);
        }

        $this->context->smarty->assign(array(
            'addresses' => $addresses,
            'customerId' => $customer->id,
            'id_carrier' => $cart->id_carrier,
            'summary' => $summary,
            'customizedDatas' => $customized_datas,
            'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE,
            'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD,
            'PS_UPLOAD_DIR' => _PS_UPLOAD_DIR_,
            'id_cart' => $cart->id,
            'showForm' => $show_form,
            'from' => $from,
            'quotationId' => $quotationId,
            'quotationName' => $quotationName,
            'ajax_url' => $this->context->link->getModuleLink('opartdevis', 'createquotation'),
        ));

J'imagine qu'il faut assigner la variable {$product.availability_message} par ici

createquotation.php OpartQuotation.php

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...