# @nacelle/sanity-plugin-pim-linker

> Link product & collection data from Nacelle in Sanity Studio

Latest version **0.1.0** (published 2021-11-15) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @nacelle/sanity-plugin-pim-linker
pnpm add @nacelle/sanity-plugin-pim-linker
yarn add @nacelle/sanity-plugin-pim-linker
bun add @nacelle/sanity-plugin-pim-linker
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2021-11-15 |
| First published | 2021-01-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 14.x |
| Dependencies | 3 |
| Unpacked size | 37.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nacelle Inc. |
| Maintainers | badiolaignacio, dzouras, leviwhalen, andrew-nacelle, nwrichmond, brianvanderson, cbodtorf, johnstonbl01, krisq, curbol, irnoble, jongeyer, alexnacelle, nacelle-bot, austin1237 |
| Keywords | sanity, plugin, nacelle, eCommerce, e-commerce |

## Links

- npm: https://www.npmjs.com/package/@nacelle/sanity-plugin-pim-linker
- Repository: https://github.com/getnacelle/nacelle-sanity-plugin-pim-linker
- Homepage: https://github.com/getnacelle/nacelle-sanity-plugin-pim-linker#readme
- Issues: https://github.com/getnacelle/nacelle-sanity-plugin-pim-linker/issues
- npm.io page: https://npm.io/package/@nacelle/sanity-plugin-pim-linker

## Dependencies (3)

- [swr](https://npm.io/package/swr.md) ^0.4.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [isomorphic-unfetch](https://npm.io/package/isomorphic-unfetch.md) ^3.1.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2021-11-15
- 0.1.0-alpha.0 (alpha) — 2021-04-28
- 1.0.0-beta.0 (beta) — 2021-03-04
- 0.0.4 — 2021-04-08
- 0.0.4-alpha.0 — 2021-04-08
- 0.0.3 — 2021-02-24
- 0.0.2 — 2021-02-08
- 0.0.1 — 2021-01-21
- 0.0.1-alpha.4 — 2021-01-21
- 0.0.1-alpha.3 — 2021-01-20
- 0.0.1-alpha.2 — 2021-01-20
- 0.0.1-alpha.1 — 2021-01-20

## README

# Sanity Custom Input Plugin: Nacelle PIM Linker

[Nacelle](https://docs.getnacelle.com/intro.html#what-is-nacelle) indexes data from your [PIM](https://en.wikipedia.org/wiki/Product_information_management) (e.g. Shopify, Magento) and CMS to power headless eCommerce projects. This plugin provides a [custom input component](https://www.sanity.io/docs/custom-input-widgets) for Sanity Studio that helps you reference product & collection data stored in Nacelle indices.

<details>
  <summary>Expand to see the custom input component in action!</summary>
  <img src="https://user-images.githubusercontent.com/5732000/105260780-65532a00-5b5c-11eb-9cc5-c5f8bddb89b4.gif" alt="The Nacelle PIM Linker component is used in Sanity Studio to select products stored in Nacelle's indices">
</details>

## Installation & Setup

### Install Peer Dependencies

`npm i @sanity/ui styled-components`

### Install the plugin

`sanity install @nacelle/sanity-plugin-pim-linker`

### Credentials

You'll need to provide the ID and Token associated with your Nacelle space. These credentials can be found in the [Nacelle Dashboard](https://dashboard.getnacelle.com/).

For a single space you can add these credentials in one of two ways:

#### in `./config/@nacelle/sanity-plugin-pim-linker.json`

```json
{
  "nacelleSpaceId": "your-nacelle-space-id",
  "nacelleSpaceToken": "your-nacelle-graphql-token"
}
```

#### in `.env.development` / `.env.production`

```
SANITY_STUDIO_NACELLE_SPACE_ID=your-nacelle-space-id
SANITY_STUDIO_NACELLE_SPACE_TOKEN=your-nacelle-graphql-token
```

For multiple spaces you can add these credentials like this:

#### in `./config/@nacelle/sanity-plugin-pim-linker.json`

```json
"nacelleSpaces": [
    {
      "spaceName": "Space 1",
      "spaceId": "your-nacelle-space-id",
      "spaceToken": "your-nacelle-graphql-token"
    },
    {
      "spaceName": "Space 2",
      "spaceId": "clever-owl-jr0WwlZv7L",
      "spaceToken": "2a74743f-7a00-4274-9cb6-2dfe15e89d47"
    }
  ]
```

## Use in Schema Documents

Set the `type` field to `nacelleData` to use the custom input component:

```js
{
  name: 'handle',
  title: 'Handle',
  type: 'nacelleData',
}
```

### Options

By default, the custom input component allows you to choose a `handle` from either products or collections.

Realistically, you probably want to restrict the component to _either_ products or collections. To do that, provide either `['products']` or `['collections']` to `options.dataType`:

```js
// example: collections ONLY
{
  name: 'collectionHandle',
  title: 'Collection',
  type: 'nacelleData',
  options: {
    dataType: ['collections']
  }
}
```

```js
// example: products ONLY
{
  name: 'productHandle',
  title: 'Product',
  type: 'nacelleData',
  options: {
    dataType: ['products']
  }
}
```

### Using This Data in Your Frontend Project

Since this custom input component just stores the `handle` of a particular product or collection, you'll use the [Nacelle Client JS SDK](https://docs.getnacelle.com/api-reference/client-js-sdk.html) to fetch the associated product or collection object.

#### Product

```js
const product = await client.data.product({
  handle: 'handle-from-my-sanity-entry'
})
```

#### Collection

```js
const collection = await client.data.collection({
  handle: 'handle-from-my-sanity-entry'
})

const productHandles = collection.productLists[0].handles

const collectionProducts = await client.data.products({
  handles: productHandles
})
```

---
_Source: https://npm.io/package/@nacelle/sanity-plugin-pim-linker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
