Jump to content

Ajout d'un champ custom dans le webservice SpecificPrice


Recommended Posts

Bonjour,

Je mets à jour les données de la table ps_specific_price via le webservice, ce qui fonctionne très bien, sauf que j'ai ajouté un champ custom dans cette table : "id_promo" (INT)

Lorsque je fais un update des données, tout passe bien, sauf le champ "id_promo", alors qu'il est bien présent dans mon XML : 

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
	<specific_price>
		<id_promo><![CDATA[2]]></id_promo>
		<id>3362240</id>
		<id_customer>0</id_customer>
		<id_product>5658</id_product>
		<id_group>0</id_group>
		<from_quantity>1</from_quantity>
		<price>-1</price>
		<id_shop>1</id_shop>
		<id_cart>0</id_cart>
		<id_currency>0</id_currency>
		<id_country>0</id_country>
		<reduction>713</reduction>
		<reduction_tax>0</reduction_tax>
		<reduction_type>amount</reduction_type>
		<from>2022-06-23 00:00:00</from>
		<to>0</to>
	</specific_price>
</prestashop>

 

J'ai surclassé la class SpecificPrice.php, en ajoutant mon champ id_promo dans les définitions : 


class SpecificPrice extends SpecificPriceCore
{
    public $id_promo;

    /**
     * @see ObjectModel::$definition
     */
    public static $definition = [
        'table' => 'specific_price',
        'primary' => 'id_specific_price',
        'fields' => [
            'id_shop_group' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
            'id_shop' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'id_promo' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'id_cart' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'id_product' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'id_product_attribute' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
            'id_currency' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'id_specific_price_rule' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
            'id_country' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'id_group' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'id_customer' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
            'price' => ['type' => self::TYPE_FLOAT, 'validate' => 'isNegativePrice', 'required' => true],
            'from_quantity' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt', 'required' => true],
            'reduction' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => true],
            'reduction_tax' => ['type' => self::TYPE_INT, 'validate' => 'isBool', 'required' => true],
            'reduction_type' => ['type' => self::TYPE_STRING, 'validate' => 'isReductionType', 'required' => true],
            'from' => ['type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => true],
            'to' => ['type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'required' => true],
        ],
    ];

Mais il semble toujours ignorer ce champ.

Pouvez-vous m'aider ? :) merci

Edited by neoweiter (see edit history)
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...