コード例 #1
0
 public function testNameValueAttributeValueArray()
 {
     $attribute = new NameValueAttribute('list', ['FOO', 'BAR']);
     $expectedXml = $this->buildExpectedXml(['name' => 'list', 'value' => ['FOO', 'BAR'], 'type' => 'STRING']);
     $this->assertEquals($expectedXml, $attribute->render());
 }
コード例 #2
0
 /**
  * Get an array of attributes that belong in the item's product attributes element.
  * Note: Attributes are only created and returned if there's a non-empty value.
  *       Attributes are to be of type STRING if they're not empty/null.
  *
  * @return array
  */
 public function getProductAttributes()
 {
     $map = ['supplier_number' => $this->legacyDistributorId, 'mds_fam_id' => $this->shipNodeSupply['mdsfamId'], 'supplier_stock_number' => $this->shipNodeSupply['vendorStockId']];
     $attributes = [];
     foreach ($map as $name => $value) {
         $attribute = new NameValueAttribute($name, $value);
         if (!$attribute->isEmpty()) {
             $attribute->setValue((string) $value);
             $attributes[] = $attribute;
         }
     }
     return $attributes;
 }
コード例 #3
0
ファイル: Item.php プロジェクト: sandisk/pangaea-php-sdk
    /**
     * Only urls need passing, the type is automatically set to PRIMARY for the first url, SECONDARY for others
     * If all urls share the same prefix, can pass that in as an optional parameter (so only need to pass unique ids)
     *
     * @param array $urls
     * @param string $urlPrefix
     */
    public function setAssets(array $urls, $urlPrefix = '')
    {
        $urls = array_filter($urls);
        foreach ($urls as $index => $asset) {
            $asset = Xml::escape($urlPrefix . $asset);
            $type = $index > 0 ? 'SECONDARY' : 'PRIMARY';
            $attribute = new NameValueAttribute('provider_name', 'asda.scene7.com');
            $this->assets .= <<<XML
<Asset>
    <assetURL>{$asset}</assetURL>
    <usageType>{$type}</usageType>
    <rank>1</rank>
    <AssetAttributes>{$attribute->render()}</AssetAttributes>
</Asset>
XML;
        }
    }