GithubHelp home page GithubHelp logo

nosto / nosto-php-sdk Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 7.0 5.86 MB

Nosto php-sdk - https://packagist.org/packages/nosto/php-sdk

License: BSD 3-Clause "New" or "Revised" License

PHP 99.91% Dockerfile 0.07% Shell 0.02%

nosto-php-sdk's People

Contributors

dairbuirabass avatar dependabot[bot] avatar jluostar avatar liangde-chen avatar mridang avatar olsi-qose avatar peter279k avatar phonglynosto avatar supercid avatar tobiasgraml11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nosto-php-sdk's Issues

Rename repository to nosto-php-sdk

When forking the repository you end up with just lsolesen/php-sdk. That makes it a little hard to know what repository it actually is without digging into the code.

Fix simple serializable objects

The markup for the simple objects should be only one html tag. For example page type must be

<span class="nosto_page_type" style="display:none">front</span>

NOT

<span class="nosto_page_type" style="display:none">
   <span class="page_type">front</span>
</span>

ToDos

  • Add setValue into MarkupableString
  • Extend MarkupableString when implementing Category, PageType and SearchTerm objects

Serialization Error of SKU Customfield-Keys

Keys with special chars like "Größe" end up like "gr":

<span class="custom_fields">
      <span class="gr">41</span>
      <span class="farbe">Weiß</span>
</span>

toJson() / API works fine!

Bubble up the sso error

Currently if the sso authentication fails, the error message and status code are discarded by sdk. That makes it difficult to debug the sso issue.

Add page type constants to SDK

The SDK is missing all the default page-type constants and these could be added to the SDK

const PAGE_TYPE_FRONT_PAGE = 'front';
const PAGE_TYPE_CART = 'cart';
const PAGE_TYPE_PRODUCT = 'product';
const PAGE_TYPE_CATEGORY = 'category';
const PAGE_TYPE_SEARCH = 'search';
const PAGE_TYPE_NOTFOUND = 'notfound';
const PAGE_TYPE_ORDER = 'order';

Add support for the thumbnail URL in the product

In order for platforms to push the thumbnail-URL from the platform itself, we should add this to the product model. This would be great when we begin adding support for Fastly on Magento and allowing retailers to serve thumbnails from their own CDN instead of us.

Add customer operation

Add possibility to send customer data over the API. Use the token API_EMAIL for authentication.

UpsertProduct Operation is not using the "toJson()" method of the Products

UpsertProduct::upsert() is using:
$response = $request->post($this->collection); to send the Products.

The ApiRequest::post() is using:
return $this->postRaw(SerializationHelper::serialize($content));

I suggest a AbstractCollection::toJson() method, which is calling the AbstractObject::toJson() method.

BONUS: Automatic UTF-8 Conversion if necessary ;-)

Add namespaces

  • remove the Nosto prefixes from classes and add proper namespaces

Separate the endpoints called from browser and server

With dockerised / virtualised environments & running Nosto locally it must be possible to separate the endpoints called from virtual machine to host and from browser to host.

For example NOSTO_WEB_HOOK_BASE_URL is used for loading the installation iframe in browser and to get the SSO url.

Add additional new fields to SDK

The new fields that are available in the tagging should be available in the SDK as well.

  • GTIN
  • Google Category
  • Alt. Image URLS
  • Rating Value
  • Review Count
  • Inventory Level
  • Supplier Cost
  • SKU

Add support for programmatic markup generation

If we can generate all the markup programmatically, then we won't need any templates in any of the extensions. Below is a snippet of code that uses a patches serializer (skips the json_encode) and passes the returned array object to this serializer.

    $x = \Nosto\Helper\SerializationHelper::serialize($product);
    echo self::toMarkup($x);

    private static function toMarkup($object, $indent = 0) {
        $markup = '';
        $spaces = str_repeat(' ', $indent);
        foreach ($object as $key => $value) {
            if (is_array($value)) {
                $output = self::toMarkup($value, $indent + 2);
                if (!empty($output)) {
                    $span = sprintf("<span class=\"%s\">", $key);
                    $endx = "</span>";
                    $markup .= $spaces . $span . PHP_EOL . $output . $spaces . $endx . PHP_EOL;
                }
            } else {
                if (!empty($value)) {
                    $span = sprintf("<span class=\"%s\">", $key);
                    $endx = "</span>";
                    $markup = $markup . $spaces . $span . $value . $endx . PHP_EOL;
                }
            }
        }
        return $markup;
    }

Here's some sample output when serializing a product:


<span class="url">http://mridang.dev.nos.to:8890/magento/210/default/breathe-easy-tank.html</span>
<span class="product_id">1817</span>
<span class="name">Breathe-Easy Tank</span>
<span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-white_main.jpg</span>
<span class="price">34</span>
<span class="list_price">34</span>
<span class="price_currency_code">EUR</span>
<span class="availability">InStock</span>
<span class="categories">
  <span class="0">/Women/Tops/Bras & Tanks</span>
  <span class="1">/Promotions/Women Sale</span>
  <span class="2">/Collections/Erin Recommends</span>
</span>
<span class="description"><p>The Breathe Easy Tank is so soft, lightweight, and comfortable, you won't even know it's there -- until its high-tech Cocona&reg; fabric starts wicking sweat away from your body to help you stay dry and focused. Layer it over your favorite sports bra and get moving.</p>
<p>&bull; Machine wash/dry.<br />&bull; Cocona&reg; fabric.</p></span>
<span class="variation_id">EUR</span>
<span class="inventory_level">1500</span>
<span class="review_count">2</span>
<span class="rating_value">3.5</span>
<span class="alternate_image_urls">
  <span class="0">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-white_back.jpg</span>
</span>
<span class="skus">
  <span class="0">
    <span class="id">1802</span>
    <span class="name">Breathe-Easy Tank-XS-Purple</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-purple_main.jpg</span>
    <span class="gtin">WT09-XS-Purple</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Purple</span>
      <span class="size">XS</span>
    </span>
  </span>
  <span class="1">
    <span class="id">1803</span>
    <span class="name">Breathe-Easy Tank-XS-White</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-white_main.jpg</span>
    <span class="gtin">WT09-XS-White</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">White</span>
      <span class="size">XS</span>
    </span>
  </span>
  <span class="2">
    <span class="id">1804</span>
    <span class="name">Breathe-Easy Tank-XS-Yellow</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-yellow_main.jpg</span>
    <span class="gtin">WT09-XS-Yellow</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Yellow</span>
      <span class="size">XS</span>
    </span>
  </span>
  <span class="3">
    <span class="id">1805</span>
    <span class="name">Breathe-Easy Tank-S-Purple</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-purple_main.jpg</span>
    <span class="gtin">WT09-S-Purple</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Purple</span>
      <span class="size">S</span>
    </span>
  </span>
  <span class="4">
    <span class="id">1806</span>
    <span class="name">Breathe-Easy Tank-S-White</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-white_main.jpg</span>
    <span class="gtin">WT09-S-White</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">White</span>
      <span class="size">S</span>
    </span>
  </span>
  <span class="5">
    <span class="id">1807</span>
    <span class="name">Breathe-Easy Tank-S-Yellow</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-yellow_main.jpg</span>
    <span class="gtin">WT09-S-Yellow</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Yellow</span>
      <span class="size">S</span>
    </span>
  </span>
  <span class="6">
    <span class="id">1808</span>
    <span class="name">Breathe-Easy Tank-M-Purple</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-purple_main.jpg</span>
    <span class="gtin">WT09-M-Purple</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Purple</span>
      <span class="size">M</span>
    </span>
  </span>
  <span class="7">
    <span class="id">1809</span>
    <span class="name">Breathe-Easy Tank-M-White</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-white_main.jpg</span>
    <span class="gtin">WT09-M-White</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">White</span>
      <span class="size">M</span>
    </span>
  </span>
  <span class="8">
    <span class="id">1810</span>
    <span class="name">Breathe-Easy Tank-M-Yellow</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-yellow_main.jpg</span>
    <span class="gtin">WT09-M-Yellow</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Yellow</span>
      <span class="size">M</span>
    </span>
  </span>
  <span class="9">
    <span class="id">1811</span>
    <span class="name">Breathe-Easy Tank-L-Purple</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-purple_main.jpg</span>
    <span class="gtin">WT09-L-Purple</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Purple</span>
      <span class="size">L</span>
    </span>
  </span>
  <span class="10">
    <span class="id">1812</span>
    <span class="name">Breathe-Easy Tank-L-White</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-white_main.jpg</span>
    <span class="gtin">WT09-L-White</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">White</span>
      <span class="size">L</span>
    </span>
  </span>
  <span class="11">
    <span class="id">1813</span>
    <span class="name">Breathe-Easy Tank-L-Yellow</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-yellow_main.jpg</span>
    <span class="gtin">WT09-L-Yellow</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Yellow</span>
      <span class="size">L</span>
    </span>
  </span>
  <span class="12">
    <span class="id">1814</span>
    <span class="name">Breathe-Easy Tank-XL-Purple</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-purple_main.jpg</span>
    <span class="gtin">WT09-XL-Purple</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Purple</span>
      <span class="size">XL</span>
    </span>
  </span>
  <span class="13">
    <span class="id">1815</span>
    <span class="name">Breathe-Easy Tank-XL-White</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-white_main.jpg</span>
    <span class="gtin">WT09-XL-White</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">White</span>
      <span class="size">XL</span>
    </span>
  </span>
  <span class="14">
    <span class="id">1816</span>
    <span class="name">Breathe-Easy Tank-XL-Yellow</span>
    <span class="price">34</span>
    <span class="list_price">34</span>
    <span class="image_url">http://mridang.dev.nos.to:8890/magento/210/pub/media/catalog/product/w/t/wt09-yellow_main.jpg</span>
    <span class="gtin">WT09-XL-Yellow</span>
    <span class="availability">InStock</span>
    <span class="custom_attributes">
      <span class="color">Yellow</span>
      <span class="size">XL</span>
    </span>
  </span>
</span>

Move the Nosto embed script fallback constant here

All the extensions using the connect.nosto.com constant have it defined in their own codebase, why not add that constant here so when you need the embed script constant, you could just invoke a method like this

function getConnectURL()
{
  return self::getEnvVariable('NOSTO_SERVER_URL', self::DEFAULT_SERVER_ADDRESS);
}

Here are some examples:

https://github.com/Nosto/nosto-magento/blob/develop/app/code/community/Nosto/Tagging/Block/Embed.php#L39
https://github.com/Nosto/nosto-magento2/blob/develop/Block/Embed.php#L60

Account object should extend a Settings object

The account object is a superset of the information of the settings object. Currently when updating the settings to Nosto, we create a NostoAccount object and then only use a small subset of the fields when serializing to JSON. This would be a lot cleaner if a had a NostoSettings object and the NostoAccount object would extend it.

Add support for new product fields

  • supplierCost
  • inventoryLevel
  • reviewCount
  • ratingValue
  • alternateImageUrls
  • condition
  • gender
  • ageGroup
  • gtin
  • googleCategory
  • unitPricingMeasure
  • unitPricingBaseMeasure
  • unitPricingUnit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.