PrestaSharp 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package PrestaSharp --version 1.0.3
NuGet\Install-Package PrestaSharp -Version 1.0.3
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PrestaSharp" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PrestaSharp --version 1.0.3
#r "nuget: PrestaSharp, 1.0.3"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PrestaSharp as a Cake Addin
#addin nuget:?package=PrestaSharp&version=1.0.3

// Install PrestaSharp as a Cake Tool
#tool nuget:?package=PrestaSharp&version=1.0.3

PrestaSharp

Total alerts Language grade: C#

CSharp .Net client library for the PrestaShop API via web service

Introduction

A simple .Net REST client written in C# for the Prestashop API. PrestaSharp uses the RestSharp library to consume the Prestashop services.

Installation

NuGet

PrestaSharp is available on NuGet. Use the package manager console to install it:

Install-Package PrestaSharp

Basic usage

  1. Initiate a client instance:
string BaseUrl = "http://www.myweb.com/api";
string Account = "ASDLKJOIQWEPROQWUPRPOQPPRQOW";
string Password = "";
ManufacturerFactory ManufacturerFactory = new ManufacturerFactory(BaseUrl, Account, Password);
  1. Perform CRUD actions through the client:
Bukimedia.PrestaSharp.Entities.manufacturer Manufacturer = ManufacturerFactory.Get(6);
Manufacturer.name = "Iron Maiden";
Manufacturer.active = 1;        
ManufacturerFactory.Add(Manufacturer);
ManufacturerFactory.Update(Manufacturer);
ManufacturerFactory.Delete(Manufacturer);
  1. Add an image:
Bukimedia.PrestaSharp.Entities.product MyProduct = new Bukimedia.PrestaSharp.Entities.product()
MyProduct = ProductFactory.Add(MyProduct)
ImageFactory.AddProductImage((long)MyProduct.id, "C:\\MyImage.jpg");

Advanced usage

  1. Get all. This sample retrieves the list of manufacturers:
List<manufacturer> manufacturers = ManufacturerFactory.GetAll();
  1. Get ids. This sample retrieves the list of the manufacturer ids:
List<long> ids = ManufacturerFactory.GetIds();
  1. Get by filter. This sample retrieves the list of manufacturers which name is "Metallica":
Dictionary<string, string> dtn = new Dictionary<string, string>();
dtn.Add("name", "Metallica");
List<manufacturer> manufacturers = ManufacturerFactory.GetByFilter(dtn, null, null);
  1. Get by filter with wildcards. This sample retrieves the manufacturers which name starts with "Metall":
Dictionary<string, string> dtn = new Dictionary<string, string>();
dtn.Add("name", "[Metall]%");
List<manufacturer> manufacturers = ManufacturerFactory.GetByFilter(dtn, null, null);
  1. Get ids by filter. This sample retrieves the list of the manufacturers ids which name is "Metallica":
Dictionary<string, string> dtn = new Dictionary<string, string>();
dtn.Add("name", "Metallica");
List<long> ids = ManufacturerFactory.GetIdsByFilter(dtn, null, null);
  1. Get ids by filter with wildcards. This sample retrieves the list of the manufacturers ids which name starts with "Metall":
Dictionary<string, string> dtn = new Dictionary<string, string>();
dtn.Add("name", "[Metall]%");
List<long> ids = ManufacturerFactory.GetIdsByFilter(dtn, null, null);
  1. Get by complex filter. This sample retrieves the top five manufacturers in ascendent sorting which name starts with "Metall":
Dictionary<string, string> dtn = new Dictionary<string, string>();
dtn.Add("name", "[Metall]%");
List<manufacturer> manufacturers = ManufacturerFactory.GetByFilter(dtn, "name_ASC", "5");
  1. Get by filter for pagination. This sample retrieves the top five manufacturers from tenth position in ascendent sorting which name starts with "Metall":
Dictionary<string, string> dtn = new Dictionary<string, string>();
dtn.Add("name", "[Metall]%");
List<manufacturer> manufacturers = ManufacturerFactory.GetByFilter(dtn, "name_ASC", "[9,5]");
  1. Get by filter by range date. This sample retrieves the orders in a date range:
DateTime StartDate = new DateTime (2016, 1, 1);
DateTime StartDate = new DateTime (2016, 1, 31);
Dictionary<string, string> filter = new Dictionary<string, string>();
string dFrom = string.Format("{0:yyyy-MM-dd HH:mm:ss}", StartDate);
string dTo = string.Format("{0:yyyy-MM-dd HH:mm:ss}", EndDate);
filter.Add("date_add", "[" + dFrom + "," + dTo + "]");
List<long> PrestaSharpOrderIds = this.OrderFactory.GetIdsByFilter(filter, "id_DESC", null);

Supported resources

  • Address
  • Carriers
  • Carts
  • Categories
  • Combinations
  • Currencies
  • Customers
  • Customer Messages
  • Customer Threads
  • Guests
  • Groups
  • Images
  • Languages
  • Manufacturers
  • Messages
  • Orders
  • Order Carriers
  • Order Cart Rules
  • Order Histories
  • Order Invoices
  • Order States
  • Products
  • Product Features
  • Product Feature Values
  • Product Options
  • Product Option Values
  • Product Suppliers
  • Shops
  • Specific Prices
  • Specific Price Rules
  • States
  • Stock Availables
  • Tags
  • Tax
  • Tax Rule
  • Tax Rule Groups
  • Warehouse
  • Zones

Supported actions

  • Create
  • Read
  • Update
  • Delete

Roadmap

  • Add other resources

Debugging

Enabling debugging in PrestaShop would make PrestaSharp exceptions more verbose, to enable that, edit /config/defines.inc.php file in your PrestaShop website and edit this code block:

define('_PS_MODE_DEV_', false);

to:

define('_PS_MODE_DEV_', false);

More information in the development section of PrestaShop's documentation.

Help & Discussion

If your problem is how to implement anything with PrestaSharp or make a question, please, refer to our Slack group: PrestaSharp Slack Group

License

PrestaSharp is GNU General Public License (GPL)

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantabilty or fitness for a particular purpose. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Bukimedia reserves the right to mention of companies or individuals who use this software.

Copyright (C) 2016 Bukimedia

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net452 is compatible.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.9 30,598 11/17/2020
1.2.8 2,381 9/1/2020
1.2.7 1,204 8/10/2020
1.1.0 9,231 10/21/2019
1.0.5 7,156 4/25/2019
1.0.4 1,247 4/9/2019
1.0.3 1,210 3/29/2019
1.0.2 1,214 3/18/2019
1.0.0 3,491 12/19/2018

Compatibility with Prestashop 1.7