Jump to content

Hook action juste après enregistrer produit


Recommended Posts

Bonjour,

Je souhaite mettre à jour une table en fonction de valeur de caractéristique.

J'ai mis le traitement sur le hookActionProductSave.

Or voici ce qu'il se passe. Je suis sur la fiche produit. Je change une valeur de caractéristique et j'enregistre. Mon traitement se passe bien MAIS avec la valeur des anciennes caractéristiques.

Si je ré enregistre le produit juste après, les nouvelles valeurs sont prises en compte.

J'en conclue que le hookActionProductSave s'execute juste avant l'enregistrement du produit.

Il y a t il un hook pour exécuter un traitement juste APRES l'enregistrement du produit ?

Merci d'avance.

Link to comment
Share on other sites

Merci beaucoup.

Je suis en 1.7.5.

J'essaye depuis ce matin de filtrer mais j'obtiens désespérément des chaines vides avec :

$this->context->controller->php_self ;

Dispatcher::getInstance()->getController();

et Tools::getValue('controller');

grrr....comment savoir sur quel controller je suis ?

 

Link to comment
Share on other sites

Sauf que je ne vois rien relatif au controller dans $params

Array
(
    [id_product] => 23
    [product] => Product Object
        (
            [tax_name] => 
            [tax_rate] => 
            [id_manufacturer] => 3
            [id_supplier] => 0
            [id_category_default] => 13
            [id_shop_default] => 1
            [manufacturer_name] => 
            [supplier_name] => 
            [name] => Array
                (
                    [1] => Château PICHON-LONGUEVILLE BARON 2007
                )

            [description] => Array
                (
                    [1] => 
                )

            [description_short] => Array
                (
                    [1] => <p>Racheté en 1986 par le groupe AXA, placé dans un premier temps sous la conduite de M. Cazes (Lynch-Bages), <strong>Pichon-Longueville Baron</strong> retrouve sa meilleure forme dans le style puissant et racé des grands Pauillac. Il faut dire qu’une petite moitié de ses vignes jouxte celles de Latour, sur un terroir de premier cru ! Pour la Revue du Vin de France : « <em>Pichon-Baron est au sommet dans les derniers millésimes</em> ».</p>
                )

            [quantity] => 0
            [minimal_quantity] => 1
            [low_stock_threshold] => 
            [low_stock_alert] => 
            [available_now] => Array
                (
                    [1] => 
                )

            [available_later] => Array
                (
                    [1] => 
                )

            [price] => 0
            [specificPrice] => 0
            [additional_shipping_cost] => 0
            [wholesale_price] => 0
            [on_sale] => 
            [online_only] => 
            [unity] => 
            [unit_price] => 0
            [unit_price_ratio] => 0.000000
            [ecotax] => 0
            [reference] => 
            [supplier_reference] => 
            [location] => 
            [width] => 0
            [height] => 0
            [depth] => 0
            [weight] => 0
            [ean13] => 
            [isbn] => 
            [upc] => 
            [link_rewrite] => Array
                (
                    [1] => chateau-pichon-longueville-baron-2016
                )

            [meta_description] => Array
                (
                    [1] => 
                )

            [meta_keywords] => Array
                (
                    [1] => 
                )

            [meta_title] => Array
                (
                    [1] => 
                )

            [quantity_discount] => 0
            [customizable] => 0
            [new] => 
            [uploadable_files] => 0
            [text_fields] => 0
            [active] => 1
            [redirect_type] => 301-category
            [id_type_redirected] => 0
            [available_for_order] => 1
            [available_date] => 
            [show_condition] => 
            [condition] => new
            [show_price] => 1
            [indexed] => 0
            [visibility] => both
            [date_add] => 2019-03-26 10:36:52
            [date_upd] => 2019-04-10 11:49:55
            [tags] => 
            [state] => 1
            [base_price] => 
            [id_tax_rules_group] => 1
            [id_color_default] => 0
            [advanced_stock_management] => 
            [out_of_stock] => 2
            [depends_on_stock] => 
            [isFullyLoaded] => 
            [cache_is_pack] => 0
            [cache_has_attachments] => 0
            [is_virtual] => 0
            [id_pack_product_attribute] => 
            [cache_default_attribute] => 43
            [category] => 
            [pack_stock_type] => 3
            [additional_delivery_times] => 1
            [delivery_in_stock] => Array
                (
                    [1] => 
                )

            [delivery_out_stock] => Array
                (
                    [1] => 
                )

            [webserviceParameters:protected] => Array
                (
                    [objectMethods] => Array
                        (
                            [add] => addWs
                            [update] => updateWs
                        )

                    [objectNodeNames] => products
                    [fields] => Array
                        (
                            [id_manufacturer] => Array
                                (
                                    [xlink_resource] => manufacturers
                                )

                            [id_supplier] => Array
                                (
                                    [xlink_resource] => suppliers
                                )

                            [id_category_default] => Array
                                (
                                    [xlink_resource] => categories
                                )

                            [new] => Array
                                (
                                )

                            [cache_default_attribute] => Array
                                (
                                )

                            [id_default_image] => Array
                                (
                                    [getter] => getCoverWs
                                    [setter] => setCoverWs
                                    [xlink_resource] => Array
                                        (
                                            [resourceName] => images
                                            [subResourceName] => products
                                        )

                                )

                            [id_default_combination] => Array
                                (
                                    [getter] => getWsDefaultCombination
                                    [setter] => setWsDefaultCombination
                                    [xlink_resource] => Array
                                        (
                                            [resourceName] => combinations
                                        )

                                )

                            [id_tax_rules_group] => Array
                                (
                                    [xlink_resource] => Array
                                        (
                                            [resourceName] => tax_rule_groups
                                        )

                                )

                            [position_in_category] => Array
                                (
                                    [getter] => getWsPositionInCategory
                                    [setter] => setWsPositionInCategory
                                )

                            [manufacturer_name] => Array
                                (
                                    [getter] => getWsManufacturerName
                                    [setter] => 
                                )

                            [quantity] => Array
                                (
                                    [getter] => 
                                    [setter] => 
                                )

                            [type] => Array
                                (
                                    [getter] => getWsType
                                    [setter] => setWsType
                                )

                        )

                    [associations] => Array
                        (
                            [categories] => Array
                                (
                                    [resource] => category
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                    [required] => 1
                                                )

                                        )

                                )

                            [images] => Array
                                (
                                    [resource] => image
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                )

                                        )

                                )

                            [combinations] => Array
                                (
                                    [resource] => combination
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                    [required] => 1
                                                )

                                        )

                                )

                            [product_option_values] => Array
                                (
                                    [resource] => product_option_value
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                    [required] => 1
                                                )

                                        )

                                )

                            [product_features] => Array
                                (
                                    [resource] => product_feature
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                    [required] => 1
                                                )

                                            [id_feature_value] => Array
                                                (
                                                    [required] => 1
                                                    [xlink_resource] => product_feature_values
                                                )

                                        )

                                )

                            [tags] => Array
                                (
                                    [resource] => tag
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                    [required] => 1
                                                )

                                        )

                                )

                            [stock_availables] => Array
                                (
                                    [resource] => stock_available
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                    [required] => 1
                                                )

                                            [id_product_attribute] => Array
                                                (
                                                    [required] => 1
                                                )

                                        )

                                    [setter] => 
                                )

                            [accessories] => Array
                                (
                                    [resource] => product
                                    [api] => products
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                    [required] => 1
                                                    [xlink_resource] => product
                                                )

                                        )

                                )

                            [product_bundle] => Array
                                (
                                    [resource] => product
                                    [api] => products
                                    [fields] => Array
                                        (
                                            [id] => Array
                                                (
                                                    [required] => 1
                                                )

                                            [quantity] => Array
                                                (
                                                )

                                        )

                                )

                        )

                )

            [id] => 23
            [id_lang:protected] => 
            [id_shop:protected] => 1
            [id_shop_list] => Array
                (
                )

            [get_shop_from_context:protected] => 1
            [table:protected] => product
            [identifier:protected] => id_product
            [fieldsRequired:protected] => Array
                (
                    [0] => price
                )

            [fieldsSize:protected] => Array
                (
                    [reference] => 64
                    [supplier_reference] => 64
                    [location] => 64
                    [ean13] => 13
                    [isbn] => 32
                    [upc] => 12
                )

            [fieldsValidate:protected] => Array
                (
                    [id_shop_default] => isUnsignedId
                    [id_manufacturer] => isUnsignedId
                    [id_supplier] => isUnsignedId
                    [reference] => isReference
                    [supplier_reference] => isReference
                    [location] => isReference
                    [width] => isUnsignedFloat
                    [height] => isUnsignedFloat
                    [depth] => isUnsignedFloat
                    [weight] => isUnsignedFloat
                    [quantity_discount] => isBool
                    [ean13] => isEan13
                    [isbn] => isIsbn
                    [upc] => isUpc
                    [cache_is_pack] => isBool
                    [cache_has_attachments] => isBool
                    [is_virtual] => isBool
                    [state] => isUnsignedId
                    [additional_delivery_times] => isUnsignedId
                    [id_category_default] => isUnsignedId
                    [id_tax_rules_group] => isUnsignedId
                    [on_sale] => isBool
                    [online_only] => isBool
                    [ecotax] => isPrice
                    [minimal_quantity] => isUnsignedInt
                    [low_stock_threshold] => isInt
                    [low_stock_alert] => isBool
                    [price] => isPrice
                    [wholesale_price] => isPrice
                    [unity] => isString
                    [additional_shipping_cost] => isPrice
                    [customizable] => isUnsignedInt
                    [text_fields] => isUnsignedInt
                    [uploadable_files] => isUnsignedInt
                    [active] => isBool
                    [redirect_type] => isString
                    [id_type_redirected] => isUnsignedId
                    [available_for_order] => isBool
                    [available_date] => isDateFormat
                    [show_condition] => isBool
                    [condition] => isGenericName
                    [show_price] => isBool
                    [indexed] => isBool
                    [visibility] => isProductVisibility
                    [advanced_stock_management] => isBool
                    [date_add] => isDate
                    [date_upd] => isDate
                    [pack_stock_type] => isUnsignedInt
                )

            [fieldsRequiredLang:protected] => Array
                (
                )

            [fieldsSizeLang:protected] => Array
                (
                    [delivery_in_stock] => 255
                    [delivery_out_stock] => 255
                    [meta_description] => 512
                    [meta_keywords] => 255
                    [meta_title] => 255
                    [link_rewrite] => 128
                    [name] => 128
                    [available_now] => 255
                    [available_later] => 255
                )

            [fieldsValidateLang:protected] => Array
                (
                    [delivery_in_stock] => isGenericName
                    [delivery_out_stock] => isGenericName
                    [meta_description] => isGenericName
                    [meta_keywords] => isGenericName
                    [meta_title] => isGenericName
                    [link_rewrite] => isLinkRewrite
                    [name] => isCatalogName
                    [description] => isCleanHtml
                    [description_short] => isCleanHtml
                    [available_now] => isGenericName
                    [available_later] => IsGenericName
                )

            [tables:protected] => Array
                (
                )

            [image_dir:protected] => 
            [image_format:protected] => jpg
            [translator:protected] => 
            [def:protected] => Array
                (
                    [table] => product
                    [primary] => id_product
                    [multilang] => 1
                    [multilang_shop] => 1
                    [fields] => Array
                        (
                            [id_shop_default] => Array
                                (
                                    [type] => 1
                                    [validate] => isUnsignedId
                                )

                            [id_manufacturer] => Array
                                (
                                    [type] => 1
                                    [validate] => isUnsignedId
                                )

                            [id_supplier] => Array
                                (
                                    [type] => 1
                                    [validate] => isUnsignedId
                                )

                            [reference] => Array
                                (
                                    [type] => 3
                                    [validate] => isReference
                                    [size] => 64
                                )

                            [supplier_reference] => Array
                                (
                                    [type] => 3
                                    [validate] => isReference
                                    [size] => 64
                                )

                            [location] => Array
                                (
                                    [type] => 3
                                    [validate] => isReference
                                    [size] => 64
                                )

                            [width] => Array
                                (
                                    [type] => 4
                                    [validate] => isUnsignedFloat
                                )

                            [height] => Array
                                (
                                    [type] => 4
                                    [validate] => isUnsignedFloat
                                )

                            [depth] => Array
                                (
                                    [type] => 4
                                    [validate] => isUnsignedFloat
                                )

                            [weight] => Array
                                (
                                    [type] => 4
                                    [validate] => isUnsignedFloat
                                )

                            [quantity_discount] => Array
                                (
                                    [type] => 2
                                    [validate] => isBool
                                )

                            [ean13] => Array
                                (
                                    [type] => 3
                                    [validate] => isEan13
                                    [size] => 13
                                )

                            [isbn] => Array
                                (
                                    [type] => 3
                                    [validate] => isIsbn
                                    [size] => 32
                                )

                            [upc] => Array
                                (
                                    [type] => 3
                                    [validate] => isUpc
                                    [size] => 12
                                )

                            [cache_is_pack] => Array
                                (
                                    [type] => 2
                                    [validate] => isBool
                                )

                            [cache_has_attachments] => Array
                                (
                                    [type] => 2
                                    [validate] => isBool
                                )

                            [is_virtual] => Array
                                (
                                    [type] => 2
                                    [validate] => isBool
                                )

                            [state] => Array
                                (
                                    [type] => 1
                                    [validate] => isUnsignedId
                                )

                            [additional_delivery_times] => Array
                                (
                                    [type] => 1
                                    [validate] => isUnsignedId
                                )

                            [delivery_in_stock] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => isGenericName
                                    [size] => 255
                                )

                            [delivery_out_stock] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => isGenericName
                                    [size] => 255
                                )

                            [id_category_default] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [validate] => isUnsignedId
                                )

                            [id_tax_rules_group] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [validate] => isUnsignedId
                                )

                            [on_sale] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [validate] => isBool
                                )

                            [online_only] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [validate] => isBool
                                )

                            [ecotax] => Array
                                (
                                    [type] => 4
                                    [shop] => 1
                                    [validate] => isPrice
                                )

                            [minimal_quantity] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [validate] => isUnsignedInt
                                )

                            [low_stock_threshold] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [allow_null] => 1
                                    [validate] => isInt
                                )

                            [low_stock_alert] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [allow_null] => 1
                                    [validate] => isBool
                                )

                            [price] => Array
                                (
                                    [type] => 4
                                    [shop] => 1
                                    [validate] => isPrice
                                    [required] => 1
                                )

                            [wholesale_price] => Array
                                (
                                    [type] => 4
                                    [shop] => 1
                                    [validate] => isPrice
                                )

                            [unity] => Array
                                (
                                    [type] => 3
                                    [shop] => 1
                                    [validate] => isString
                                )

                            [unit_price_ratio] => Array
                                (
                                    [type] => 4
                                    [shop] => 1
                                )

                            [additional_shipping_cost] => Array
                                (
                                    [type] => 4
                                    [shop] => 1
                                    [validate] => isPrice
                                )

                            [customizable] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [validate] => isUnsignedInt
                                )

                            [text_fields] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [validate] => isUnsignedInt
                                )

                            [uploadable_files] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [validate] => isUnsignedInt
                                )

                            [active] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [validate] => isBool
                                )

                            [redirect_type] => Array
                                (
                                    [type] => 3
                                    [shop] => 1
                                    [validate] => isString
                                )

                            [id_type_redirected] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [validate] => isUnsignedId
                                )

                            [available_for_order] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [validate] => isBool
                                )

                            [available_date] => Array
                                (
                                    [type] => 5
                                    [shop] => 1
                                    [validate] => isDateFormat
                                )

                            [show_condition] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [validate] => isBool
                                )

                            [condition] => Array
                                (
                                    [type] => 3
                                    [shop] => 1
                                    [validate] => isGenericName
                                    [values] => Array
                                        (
                                            [0] => new
                                            [1] => used
                                            [2] => refurbished
                                        )

                                    [default] => new
                                )

                            [show_price] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [validate] => isBool
                                )

                            [indexed] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [validate] => isBool
                                )

                            [visibility] => Array
                                (
                                    [type] => 3
                                    [shop] => 1
                                    [validate] => isProductVisibility
                                    [values] => Array
                                        (
                                            [0] => both
                                            [1] => catalog
                                            [2] => search
                                            [3] => none
                                        )

                                    [default] => both
                                )

                            [cache_default_attribute] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                )

                            [advanced_stock_management] => Array
                                (
                                    [type] => 2
                                    [shop] => 1
                                    [validate] => isBool
                                )

                            [date_add] => Array
                                (
                                    [type] => 5
                                    [shop] => 1
                                    [validate] => isDate
                                )

                            [date_upd] => Array
                                (
                                    [type] => 5
                                    [shop] => 1
                                    [validate] => isDate
                                )

                            [pack_stock_type] => Array
                                (
                                    [type] => 1
                                    [shop] => 1
                                    [validate] => isUnsignedInt
                                )

                            [meta_description] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => isGenericName
                                    [size] => 512
                                )

                            [meta_keywords] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => isGenericName
                                    [size] => 255
                                )

                            [meta_title] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => isGenericName
                                    [size] => 255
                                )

                            [link_rewrite] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => isLinkRewrite
                                    [required] => 
                                    [size] => 128
                                    [ws_modifier] => Array
                                        (
                                            [http_method] => 2
                                            [modifier] => modifierWsLinkRewrite
                                        )

                                )

                            [name] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => isCatalogName
                                    [required] => 
                                    [size] => 128
                                )

                            [description] => Array
                                (
                                    [type] => 6
                                    [lang] => 1
                                    [validate] => isCleanHtml
                                )

                            [description_short] => Array
                                (
                                    [type] => 6
                                    [lang] => 1
                                    [validate] => isCleanHtml
                                    [size] => 833
                                )

                            [available_now] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => isGenericName
                                    [size] => 255
                                )

                            [available_later] => Array
                                (
                                    [type] => 3
                                    [lang] => 1
                                    [validate] => IsGenericName
                                    [size] => 255
                                )

                        )

                    [associations] => Array
                        (
                            [manufacturer] => Array
                                (
                                    [type] => 1
                                )

                            [supplier] => Array
                                (
                                    [type] => 1
                                )

                            [default_category] => Array
                                (
                                    [type] => 1
                                    [field] => id_category_default
                                    [object] => Category
                                )

                            [tax_rules_group] => Array
                                (
                                    [type] => 1
                                )

                            [categories] => Array
                                (
                                    [type] => 2
                                    [field] => id_category
                                    [object] => Category
                                    [association] => category_product
                                )

                            [stock_availables] => Array
                                (
                                    [type] => 2
                                    [field] => id_stock_available
                                    [object] => StockAvailable
                                    [association] => stock_availables
                                )

                            [l] => Array
                                (
                                    [type] => 2
                                    [field] => id_product
                                    [foreign_field] => id_product
                                )

                        )

                    [classname] => Product
                )

            [update_fields:protected] => 
            [force_id] => 
        )

    [cookie] => Cookie Object
        (
            [_content:protected] => Array
                (
                    [date_add] => 2019-03-25 14:51:49
                    [id_lang] => 1
                    [detect_language] => 1
                    [id_employee] => 1
                    [email] => [email protected]
                    [profile] => 1
                    [passwd] => $2y$10$EHSyXeiFyhYRz0bpCzj9DObIzgp8VAry4BStp/stiHJmdRIeO50.S
                    [remote_addr] => -1753271942
                    [shopContext] => s-1
                    [checksum] => 1470501473
                )

            [_name:protected] => PrestaShop-db06bea1123bf904f18d0f1785e65801
            [_expire:protected] => 1556617794
            [_domain:protected] => www.prestashop.lenclosdesvins.com
            [_path:protected] => /
            [cipherTool:protected] => PhpEncryption Object
                (
                )

            [_modified:protected] => 
            [_allow_writing:protected] => 1
            [_salt:protected] => Kma9JhHo
            [_standalone:protected] => 
            [_secure:protected] => 
        )

    [cart] => 
    [altern] => 2
)

 

Link to comment
Share on other sites

tu as l'objet tu sais que c'est un produit (ton filtre)

Tu vérifies que l'origine est le BO (PS_ADMIN_DIR existe et est bien un chemin existant)

Tu ne pourra pas vraiment connaitre le contrôleur, mais rien ne t'empèche d'ajouter un champs dans le form et de tester sa présence dans ton hook

 

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...