Youssef Posted September 5, 2018 Share Posted September 5, 2018 Hi all, I need to get newsletter records using the prestashop webservice, but I can't find the newsletter table in the webservice admin panel. When I try to perform a GET action with this link "http://127.0.0.1/modules/prestashop/api/newsletters", I have this message in return : Quote <![CDATA[ Resource of type "newsletters" does not exists. Did you mean: "suppliers"? The full list is: "addresses", "carriers", "cart_rules", "carts", "categories", "combinations", "configurations", "contacts", "content_management_system", "countries", "currencies", "customer_messages", "customer_threads", "customers", "deliveries", "employees", "groups", "guests", "image_types", "images", "languages", "manufacturers", "order_carriers", "order_details", "order_discounts", "order_histories", "order_invoices", "order_payments", "order_slip", "order_states", "orders", "price_ranges", "product_feature_values", "product_features", "product_option_values", "product_options", "product_suppliers", "products", "search", "shop_groups", "shops", "specific_price_rules", "specific_prices", "states", "stock_availables", "stock_movement_reasons", "stock_movements", "stocks", "stores", "suppliers", "supply_order_details", "supply_order_histories", "supply_order_receipt_histories", "supply_order_states", "supply_orders", "tags", "tax_rule_groups", "tax_rules", "taxes", "translated_configurations", "warehouse_product_locations", "warehouses", "weight_ranges", "zones" ]]> Could you help me finding a way to make the newsletter table accessible via webservice ? Thanks Link to comment Share on other sites More sharing options...
Knowband Plugins Posted September 5, 2018 Share Posted September 5, 2018 2 hours ago, Youssef said: Hi all, I need to get newsletter records using the prestashop webservice, but I can't find the newsletter table in the webservice admin panel. When I try to perform a GET action with this link "http://127.0.0.1/modules/prestashop/api/newsletters", I have this message in return : Could you help me finding a way to make the newsletter table accessible via webservice ? Thanks By default, newsletter table is not accessible through the webservices but you can access the same. You need to perform the following things. 1. Create a newsletter class inside the classes folder similar to cart, customer class. 2. After that add a line in classes/webservice/WebserviceRequest.php (Inside getResources function) similar to other resources like cart, customers etc. Link to comment Share on other sites More sharing options...
Youssef Posted September 5, 2018 Author Share Posted September 5, 2018 (edited) Thanks for your reply, it helped me a lot ! That's how I solved it properly: 1. Create a newsletter class (Newsletter.php) inside the override/classes folder : class NewsletterCore extends ObjectModel { public $id_shop; public $id_shop_group; public $email; public $newsletter_date_add; public $ip_registration_newsletter; public $active; public static $definition = array( 'table' => 'newsletter', 'primary' => 'id', 'fields' => array( 'id_shop' => array('type' => self::TYPE_INT), 'id_shop_group' => array('type' => self::TYPE_INT), 'email' => array('type' => self::TYPE_STRING), 'newsletter_date_add' => array('type' => self::TYPE_DATE), 'ip_registration_newsletter' => array('type' => self::TYPE_STRING), 'http_referer' => array('type' => self::TYPE_STRING), 'active' => array('type' => self::TYPE_INT), ) ); protected $webserviceParameters = array(); } 2. Create the class (WebserviceRequest.php) inside the override/classes/webservice folder : class WebserviceRequest extends WebserviceRequestCore { public static function getResources(){ $resources = parent::getResources(); $resources['newsletters'] = array('description' => 'Newsletters', 'class' => 'Newsletter'); ksort($resources); return $resources; } } 3. Disable the cache for the new update to take effect (Administration Panel -> Advanced Settings -> Performance) Edited September 5, 2018 by Youssef (see edit history) 1 Link to comment Share on other sites More sharing options...
Knowband Plugins Posted September 5, 2018 Share Posted September 5, 2018 57 minutes ago, Youssef said: Thanks for your reply, it helped me a lot ! That's how I solved it properly: 1. Create a newsletter class (Newsletter.php) inside the override/classes folder : class NewsletterCore extends ObjectModel { public $id_shop; public $id_shop_group; public $email; public $newsletter_date_add; public $ip_registration_newsletter; public $active; public static $definition = array( 'table' => 'newsletter', 'primary' => 'id', 'fields' => array( 'id_shop' => array('type' => self::TYPE_INT), 'id_shop_group' => array('type' => self::TYPE_INT), 'email' => array('type' => self::TYPE_STRING), 'newsletter_date_add' => array('type' => self::TYPE_DATE), 'ip_registration_newsletter' => array('type' => self::TYPE_STRING), 'http_referer' => array('type' => self::TYPE_STRING), 'active' => array('type' => self::TYPE_INT), ) ); protected $webserviceParameters = array(); } 2. Create the class (WebserviceRequest.php) inside the override/classes/webservice folder : class WebserviceRequest extends WebserviceRequestCore { public static function getResources(){ $resources = parent::getResources(); $resources['newsletters'] = array('description' => 'Newsletters', 'class' => 'Newsletter'); ksort($resources); return $resources; } } 3. Disable the cache for the new update to take effect (Administration Panel -> Advanced Settings -> Performance) Great Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now