

# Reading from WooCommerce entities
<a name="woocommerce-reading-from-entities"></a>

**Prerequisite**

A WooCommerce object you would like to read from. You will need the object name such as coupon, order, product, etc.

**Supported entities for source**:


| Entity | Can be filtered | Supports limit | Supports Order by | Supports Select \$1 | Supports partitioning | 
| --- | --- | --- | --- | --- | --- | 
| Coupon | Yes | Yes | Yes | Yes | Yes | 
| Coupon Total | No | No | No | Yes | No | 
| Customers Total | No | No | No | Yes | No | 
| Order | Yes | Yes | Yes | Yes | Yes | 
| Orders Total | No | No | No | Yes | No | 
| Payment Gateway | No | No | No | Yes | No | 
| Product | Yes | Yes | Yes | Yes | Yes | 
| Product attribute | Yes | Yes | Yes | Yes | Yes | 
| Product category | Yes | Yes | Yes | Yes | Yes | 
| Product review | Yes | Yes | Yes | Yes | Yes | 
| Product shipping class | Yes | Yes | Yes | Yes | Yes | 
| Product tag | Yes | Yes | Yes | Yes | Yes | 
| Product variation | Yes | Yes | Yes | Yes | Yes | 
| Products Total | No | No | No | Yes | No | 
| Report (List) | No | No | No | Yes | No | 
| Reviews Total | No | No | No | Yes | No | 
| Sales Report | Yes | No | No | Yes | No | 
| Shipping Method | No | No | No | Yes | No | 
| Shipping Zone | No | No | No | Yes | No | 
| Shipping Zone Location | No | No | No | Yes | No | 
| Shipping Zone Method | No | No | No | Yes | No | 
| Tax Rate | Yes | Yes | Yes | Yes | Yes | 
| Tax Class | No | No | No | Yes | No | 
| Top Sellers Report | Yes | No | No | Yes | No | 

**Example**:

```
woocommerce_read = glueContext.create_dynamic_frame.from_options(
    connection_type="glue.spark.woocommerce",
    connection_options={
        "connectionName": "connectionName",
        "ENTITY_NAME": "coupon",
        "API_VERSION": "v3",
        "INSTANCE_URL": "instanceUrl"
    }
```

**WooCommerce entity and field details**:

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/glue/latest/dg/woocommerce-reading-from-entities.html)

**Note**  
Struct and List data types are converted to String data type, and DateTime data type is converted to Timestamp in the response of the connectors.

## Partitioning queries
<a name="woocommerce-reading-partitioning-queries"></a>

**Record-based partitioning**:

You can provide the additional Spark option `NUM_PARTITIONS` if you want to utilize concurrency in Spark. With these parameters, the original query would be split into `NUM_PARTITIONS` number of sub-queries that can be executed by Spark tasks concurrently.

In record-based partitioning, the total number of records present is queried from the WooCommerce API, and divided by a `NUM_PARTITIONS` number provided. The resulting number of records are then concurrently fetched by each sub-query.
+ `NUM_PARTITIONS`: the number of partitions.

The following entities support record-based partitioning:
+ coupon
+ order
+ product
+ product-attribute
+ product-attribute-term
+ product-category
+ product-review
+ product-shipping-class
+ product-tag
+ product-variation
+ tax-rate

Example:

```
woocommerce_read = glueContext.create_dynamic_frame.from_options(
    connection_type="glue.spark.woocommerce",
    connection_options={
        "connectionName": "connectionName",
        "ENTITY_NAME": "coupon",
        "API_VERSION": "v3",
        "INSTANCE_URL": "instanceUrl"
        "NUM_PARTITIONS": "10"
    }
```

**Record-based partitioning**:

The original query is splitinto `NUM_PARTITIONS` number of sub-queries that can be executed by Spark tasks concurrently:
+ `NUM_PARTITIONS`: the number of partitions.

Example:

```
WooCommerce_read = glueContext.create_dynamic_frame.from_options(
    connection_type="WooCommerce",
    connection_options={
        "connectionName": "connectionName",
        "REALMID": "1234567890123456789",
        "ENTITY_NAME": "Bill",
        "API_VERSION": "v3",
        "NUM_PARTITIONS": "10"
    }
```