public function getProductObj($divaProduct, $sku)
 {
     $id_product = $sku["id_product"];
     $id_sku = $sku["id_sku"];
     $is_parent = $sku["is_parent"];
     $has_children = empty($sku["attribute"]) ? false : true;
     $size = empty($sku["attribute"]) ? "One Size" : $sku["attribute"]["attribute_name"];
     $amazonProduct = new MarketplaceWebService_XML_Data_Clothing();
     $amazonProduct->setSKU($id_sku);
     $categories = $divaProduct->getCategories();
     if (in_array(CAT_SAREE, $categories)) {
         $size_str = $size;
         $measurements = array();
         if (isset($divaProduct->width)) {
             $divaProduct->width = trim($divaProduct->width);
             if (!empty($divaProduct->width)) {
                 array_push($measurements, "Length:" . (string) $divaProduct->height . " meter");
             }
         }
         if (isset($divaProduct->height)) {
             $divaProduct->height = trim($divaProduct->height);
             if (!empty($divaProduct->height)) {
                 array_push($measurements, "Width:" . (string) $divaProduct->width . " inch");
             }
         }
         if (isset($divaProduct->blouse_length)) {
             $divaProduct->blouse_length = trim($divaProduct->blouse_length);
             if (!empty($divaProduct->blouse_length)) {
                 array_push($measurements, "Blouse Length:" . (string) $divaProduct->blouse_length . " cm");
             }
         }
         if (!empty($measurements)) {
             $amazonProduct->addBulletPoint(implode(" - ", $measurements));
         }
         $amazonProduct->addBulletPoint("Saree is an elegant Indian outfit,this Sari also comes with an unstitched attached blouse fabric.");
         $amazonProduct->addSearchTerms("sarees from india");
         $amazonProduct->addSearchTerms("saree with blouse");
         $amazonProduct->addSearchTerms("sareez");
         $amazonProduct->addSearchTerms("sarees for women");
         $amazonProduct->addSearchTerms("indian dress");
     } else {
         if (in_array(CAT_CHOLIS, $categories)) {
             //No specific attributes
             $size_str = "Bust : {$size} inch";
             $amazonProduct->addBulletPoint("Choli blouses from India, pair it with any saree or Lehenga skirt of your choice.");
             $amazonProduct->addSearchTerms("choli top");
             $amazonProduct->addSearchTerms("choli dress");
             $amazonProduct->addSearchTerms("choli blouse");
             $amazonProduct->addSearchTerms("indian choli");
             $amazonProduct->addSearchTerms("choli for lehenga");
         } else {
             if (in_array(CAT_SKD, $categories) || in_array(CAT_KURTI, $categories)) {
                 $size_str = "Bust : {$size} inch";
                 $styles = array();
                 if (isset($divaProduct->kameez_style)) {
                     $divaProduct->kameez_style = trim($divaProduct->kameez_style);
                     if (!empty($divaProduct->kameez_style)) {
                         array_push($styles, "Kameez Style: " . (string) $divaProduct->kameez_style);
                     }
                 }
                 if (isset($divaProduct->salwar_style)) {
                     $divaProduct->salwar_style = trim($divaProduct->salwar_style);
                     if (!empty($divaProduct->salwar_style)) {
                         array_push($styles, "Salwar Style: " . (string) $divaProduct->salwar_style);
                     }
                 }
                 if (isset($divaProduct->sleeves)) {
                     $divaProduct->sleeves = trim($divaProduct->sleeves);
                     if (!empty($divaProduct->sleeves)) {
                         array_push($styles, "Sleeves: " . (string) $divaProduct->sleeves);
                     }
                 }
                 if (!empty($styles)) {
                     $amazonProduct->addBulletPoint(implode(" - ", $styles));
                 }
                 if (in_array(CAT_SKD, $categories)) {
                     $amazonProduct->addBulletPoint("Our Salwar Kameez set is fit for all occasions, an ensemble that completes your wardrobe.");
                     $amazonProduct->addSearchTerms("Salwar Kameez Readymade");
                     if (in_array(CAT_ANARKALI, $categories)) {
                         $amazonProduct->addSearchTerms("Salwar Kameez Anarkali");
                     } else {
                         $amazonProduct->addSearchTerms("Salwar Kameez Set");
                     }
                     $amazonProduct->addSearchTerms("Salwar Kameez Women");
                     $amazonProduct->addSearchTerms("Chiridar Salwar Kameez");
                     $amazonProduct->addSearchTerms("Salwar Kameez from India");
                 }
                 if (in_array(CAT_KURTI, $categories)) {
                     $amazonProduct->addBulletPoint("A Kurti is trendy and easy to wear, the best from our kurtis and tunics collection.");
                     $amazonProduct->addSearchTerms("Kurti for Women");
                     $amazonProduct->addSearchTerms("Indian Kurti for Women");
                     $amazonProduct->addSearchTerms("Kurti tops");
                     $amazonProduct->addSearchTerms("Kurtis from India");
                     $amazonProduct->addSearchTerms("Kurti Tunics");
                 }
             } else {
                 if (in_array(CAT_BOTTOMS, $categories)) {
                     if (in_array(493, $categories)) {
                         $size_str = $size;
                     } else {
                         $size_str = "Waist : {$size} inch";
                     }
                     $amazonProduct->addBulletPoint("Bottoms for Salwar Sets and Kurtis from India, casual and comfortable.");
                     $amazonProduct->addSearchTerms("Bottoms Women");
                     $amazonProduct->addSearchTerms("Bottom Pants");
                     $amazonProduct->addSearchTerms("Indian Bottom");
                     $amazonProduct->addSearchTerms("Salwar Bottom");
                 } else {
                     if (in_array(CAT_LEHENGA, $categories)) {
                         $size_str = "Bust : {$size} inch";
                         $amazonProduct->addBulletPoint("Lehenga Choli Dresses from India are a style statement, the best Lehenga skirts for women are here.");
                         $amazonProduct->addSearchTerms("Lehenga Choli for women");
                         $amazonProduct->addSearchTerms("Lehenga Skirt");
                         $amazonProduct->addSearchTerms("Lehenga Choli exotic India");
                         $amazonProduct->addSearchTerms("Lehenga Choli Skirt");
                         $amazonProduct->addSearchTerms("Lehenga Dress");
                     } else {
                         if (in_array(CAT_MEN, $categories)) {
                             $size_str = "Chest : {$size} inch";
                             $amazonProduct->addBulletPoint("Ethnic Indian menswear.");
                             $amazonProduct->addSearchTerms("Men");
                             $amazonProduct->addSearchTerms("Clothing");
                             $amazonProduct->addSearchTerms("Menswear");
                             $amazonProduct->addSearchTerms("Ethnic");
                             $amazonProduct->addSearchTerms("Kurtas");
                         } else {
                             throw new Exception("Product not falling in the allowed category list");
                             return;
                         }
                     }
                 }
             }
         }
     }
     // Prefix with IndusDiva Women's if possible
     $pretext = "IndusDiva Women's ";
     if (in_array(CAT_MEN, $categories)) {
         $pretext = "IndusDiva Men's ";
     } else {
         if (in_array(CAT_KIDS, $categories)) {
             $pretext = "IndusDiva Kids ";
         }
     }
     // Prefix with just IndusDiva atleast if possible
     if (strlen($divaProduct->name . $pretext) > 80) {
         $pretext = "IndusDiva ";
         if (strlen($divaProduct->name . $pretext) > 80) {
             $pretext = "";
         }
     }
     $amazonProduct->setTitle($pretext . (string) $divaProduct->name);
     $amazonProduct->setBrand('IndusDiva');
     $amazonProduct->setDescription((string) $divaProduct->description);
     $amazonProduct->setMerchantCatalogNumber((string) $divaProduct->reference);
     $condition = new MarketplaceWebService_XML_DataType_Condition("New");
     $amazonProduct->setCondition($condition);
     $amazonProduct->setItemType("Novelty Dresses");
     $amazonProduct->setIsGiftWrapAvailable(false);
     $amazonProduct->setIsGiftMessageAvailable(false);
     if ($is_parent === false && $has_children === false) {
         $amazonProduct->setSize($size_str);
         $amazon_size = MarketplaceWebService_AmazonDataMap::getAmazonSize($size);
         if ($amazon_size !== null) {
             $amazonProduct->setSizeMap($amazon_size);
         }
     } else {
         if ($is_parent) {
             $amazonProduct->setParentage("parent");
             $amazonProduct->setVariationTheme("Size");
         } else {
             $amazonProduct->setParentage("child");
             $amazonProduct->setVariationTheme("Size");
             $amazonProduct->setSize($size_str);
             $amazon_size = MarketplaceWebService_AmazonDataMap::getAmazonSize($size);
             if ($amazon_size !== null) {
                 $amazonProduct->setSizeMap($amazon_size);
             }
         }
     }
     if (isset($divaProduct->color) && !empty($divaProduct->color)) {
         $amazonProduct->setColor((string) $divaProduct->color);
     }
     if (isset($divaProduct->generic_color) && !empty($divaProduct->generic_color)) {
         $amazon_color = MarketplaceWebService_AmazonDataMap::getAmazonColor((string) $divaProduct->generic_color);
         if ($amazon_color !== null) {
             $amazonProduct->setColorMap($amazon_color);
         }
     }
     $amazonProduct->setClothingType('Dress');
     $model_number = "ID-{$id_product}";
     $amazonProduct->setModelNumber($id_sku);
     $wash_care = "Dry cleaning is the best method to wash";
     $amazonProduct->setFabricWash($wash_care);
     if (in_array(CAT_MEN, $categories)) {
         $amazonProduct->setTargetGender('male');
         $amazonProduct->addDepartment('mens');
     } else {
         $amazonProduct->setTargetGender('female');
         $amazonProduct->addDepartment('womens');
     }
     if (isset($divaProduct->work_type) && !empty($divaProduct->work_type)) {
         $amazonProduct->addBulletPoint("Work type:" . (string) $divaProduct->work_type);
     }
     if (isset($divaProduct->garment_type) && !empty($divaProduct->garment_type)) {
         $amazonProduct->addBulletPoint("Garment type:" . (string) $divaProduct->garment_type);
     }
     /*if( is_array($divaProduct->tags) ) {
           $tt = 1;
           foreach($divaProduct->tags[1] as $tag) {
               $amazonProduct->addSearchTerms((string)$tag);
               $tt++;
               if( $tt ===  5)
                   break;
           }
       }*/
     if (isset($divaProduct->fabric) && !empty($divaProduct->fabric)) {
         $amazonProduct->addMaterialAndFabric((string) $divaProduct->fabric);
     }
     if (stripos((string) $divaProduct->fabric, 'silk') !== false) {
         $care_instructions = "For silk apparel, it is necessary that one keeps it covered by a cotton cloth, always.Being a pure natural fabric, they need abundant breathing and cotton is one of the few materials which allow this. Never wrap silk apparel in plastic and trap the moisture; this could change the color and quality of the fabric in no time. Additionally always keep it free from moths by using cedar sticks.";
         $amazonProduct->setCareInstructions($care_instructions);
     }
     return $amazonProduct;
 }
 public function getProductObj($divaProduct, $sku)
 {
     $id_product = $sku["id_product"];
     $id_sku = $sku["id_sku"];
     $is_parent = $sku["is_parent"];
     $has_children = empty($sku["attribute"]) ? false : true;
     $size = empty($sku["attribute"]) ? "One Size" : $sku["attribute"]["attribute_name"];
     $amazonProduct = new MarketplaceWebService_XML_Data_Jewelry();
     $amazonProduct->setSKU($id_sku);
     // Prefix with IndusDiva Women's if possible
     $pretext = "IndusDiva Women's ";
     if (strlen($divaProduct->name) <= 80 - strlen($pretext)) {
         $amazonProduct->setTitle($pretext . (string) $divaProduct->name);
     } else {
         // Prefix with just IndusDiva atleast if possible
         $pretext = "IndusDiva ";
         if (strlen($divaProduct->name) <= 80 - strlen($pretext)) {
             $amazonProduct->setTitle($pretext . (string) $divaProduct->name);
         } else {
             // Add the Title as it is
             $amazonProduct->setTitle((string) $divaProduct->name);
         }
     }
     $amazonProduct->setBrand('IndusDiva');
     $amazonProduct->setDescription((string) $divaProduct->description);
     $amazonProduct->setMerchantCatalogNumber((string) $divaProduct->reference);
     $condition = new MarketplaceWebService_XML_DataType_Condition("New");
     $amazonProduct->setCondition($condition);
     $amazonProduct->setIsGiftWrapAvailable(false);
     $amazonProduct->setIsGiftMessageAvailable(false);
     $model_number = "ID-{$id_product}";
     $amazonProduct->setModelNumber($id_sku);
     if (isset($divaProduct->dimensions) && !empty($divaProduct->dimensions)) {
         $amazonProduct->addBulletPoint("Dimensions:" . (string) $divaProduct->dimensions);
     }
     if (isset($divaProduct->look) && !empty($divaProduct->look)) {
         $amazonProduct->addBulletPoint("Look:" . (string) $divaProduct->look);
     }
     $categories = $divaProduct->getCategories();
     $metal_type = null;
     $metal_types = array("2 Colour Gold", "3 Colour Gold", "Base Metal", "Brass", "Copper", "Gold Plated", "Oxidized Gold", "Oxidized Silver", "Palladium", "Platinum", "Platinum Plated", "Rose Gold", "Silver", "Silver Plated", "Stainless Steel", "Titanium", "Tungsten", "Vermeil", "White Gold", "Yellow Gold");
     foreach ($metal_types as $m) {
         if (stripos($m, $divaProduct->name) !== false || stripos($m, $divaProduct->description) !== false || stripos($m, $divaProduct->material) !== false) {
             $metal_type = $m;
             break;
         }
     }
     $item_shape = null;
     $item_shapes = array("Bangle", "Bangle Set", "Chain", "Charm", "Choker", "Cuff & Kadaa", "Mangalsutra", "Multi-Strand", "Pendant", "Strand", "Clip-On", "Dangle & Drop", "Hoop", "Jhumki", "Stud");
     foreach ($item_shapes as $m) {
         if (stripos($m, $divaProduct->name) !== false || stripos($m, $divaProduct->description) !== false || stripos($m, $divaProduct->material) !== false) {
             $item_shape = $m;
             break;
         }
     }
     if (in_array(460, $categories)) {
         $earring = new MarketplaceWebService_XML_DataType_FashionEarring();
         if (isset($divaProduct->generic_color) && !empty($divaProduct->generic_color)) {
             $amazon_color = MarketplaceWebService_AmazonDataMap::getAmazonColor((string) $divaProduct->generic_color);
             if ($amazon_color !== null) {
                 $earring->setColorMap($amazon_color);
             }
         }
         $earring->addStone($divaProduct->stone);
         $earring->addMaterial($divaProduct->material);
         $earring->setDepartmentName('womens');
         $earring->setMetalType($metal_type);
         $earring->setItemShape($item_shape);
         $earring->setOccasionType($divaProduct->occasion);
         $amazonProduct->setProductType($earring);
     } elseif (in_array(455, $categories) || in_array(465, $categories)) {
         $neckwear = new MarketplaceWebService_XML_DataType_FashionNecklaceBraceletAnklet();
         if (isset($divaProduct->generic_color) && !empty($divaProduct->generic_color)) {
             $amazon_color = MarketplaceWebService_AmazonDataMap::getAmazonColor((string) $divaProduct->generic_color);
             if ($amazon_color !== null) {
                 $neckwear->setColorMap($amazon_color);
             }
         }
         if (isset($divaProduct->stone) && !empty($divaProduct->stone)) {
             $neckwear->addStone($divaProduct->stone);
         }
         if (isset($divaProduct->material) && !empty($divaProduct->material)) {
             $neckwear->addMaterial($divaProduct->material);
         }
         $neckwear->setDepartmentName('womens');
         $neckwear->setMetalType($metal_type);
         $neckwear->setItemShape($item_shape);
         $neckwear->setOccasionType($divaProduct->occasion);
         $amazonProduct->setProductType($neckwear);
     } elseif (in_array(475, $categories)) {
         $other = new MarketplaceWebService_XML_DataType_FashionOther();
         if (isset($divaProduct->generic_color) && !empty($divaProduct->generic_color)) {
             $amazon_color = MarketplaceWebService_AmazonDataMap::getAmazonColor((string) $divaProduct->generic_color);
             if ($amazon_color !== null) {
                 $other->setColorMap($amazon_color);
             }
         }
         $other->addStone($divaProduct->stone);
         $other->addMaterial($divaProduct->material);
         $other->setDepartmentName('womens');
         $other->setMetalType($metal_type);
         $other->setItemShape($item_shape);
         $other->setOccasionType($divaProduct->occasion);
         $amazonProduct->setProductType($other);
     }
     return $amazonProduct;
 }
Beispiel #3
0
 public function createProduct($p, $parentageData, $attribute = null)
 {
     $isParent = $parentageData['isParent'];
     $isChild = $parentageData['isChild'];
     $hasChildren = $parentageData['hasChildren'];
     if (!$isParent && $isChild && !empty($attribute)) {
         $id_sku = "ID-" . (int) $p->id . "-" . $attribute['attribute_name'];
     } else {
         $id_sku = "ID-" . (int) $p->id;
     }
     $product = $this->message->appendChild($this->createNode('Product'));
     $product->appendChild($this->createNode('SKU', $id_sku));
     $condition = $product->appendChild($this->createNode('Condition'));
     $condition->appendChild($this->createNode('ConditionType', 'New'));
     $description = $product->appendChild($this->createNode('DescriptionData'));
     $description->appendChild($this->createNode('Title', (string) $p->name));
     $description->appendChild($this->createNode('Brand', 'IndusDiva'));
     $description->appendChild($this->createNode('Description', (string) $p->description));
     //Bullet Points
     if (isset($p->work_type) && $p->work_type != '') {
         $description->appendChild($this->createNode('BulletPoint', (string) $p->work_type));
     }
     if (isset($p->garment_type) && $p->garment_type != '') {
         $description->appendChild($this->createNode('BulletPoint', (string) $p->garment_type));
     }
     $measurements = array();
     if (isset($p->width)) {
         $p->width = trim($p->width);
         if (!empty($p->width)) {
             array_push($measurements, "Length:" . (string) $p->height . " cm");
         }
     }
     if (isset($p->height)) {
         $p->height = trim($p->height);
         if (!empty($p->height)) {
             array_push($measurements, "Width:" . (string) $p->width . " meters");
         }
     }
     if (isset($p->blouse_length)) {
         $p->blouse_length = trim($p->blouse_length);
         if (!empty($p->blouse_length)) {
             array_push($measurements, "Blouse Length:" . (string) $p->blouse_length . " inches");
         }
     }
     if (!empty($measurements)) {
         $description->appendChild($this->createNode('BulletPoint', implode(" - ", $measurements)));
     }
     $description->appendChild($this->createNode('MerchantCatalogNumber', (string) $p->reference));
     $tt = 0;
     if (is_array($p->tags)) {
         foreach ($p->tags[1] as $tag) {
             $description->appendChild($this->createNode('SearchTerms', (string) $tag));
             if (++$tt > 5) {
                 break;
             }
         }
     }
     $description->appendChild($this->createNode('ItemType', "world-apparel"));
     $description->appendChild($this->createNode('IsGiftWrapAvailable', "false"));
     $description->appendChild($this->createNode('IsGiftMessageAvailable', "false"));
     $product_data = $product->appendChild($this->createNode('ProductData'));
     $clothing = $product_data->appendChild($this->createNode("Clothing"));
     $vdata = $clothing->appendChild($this->createNode('VariationData'));
     if ($isParent || $isChild) {
         $parentage = $isParent ? 'parent' : 'child';
         $vdata->appendChild($this->createNode('Parentage', $parentage));
     }
     if (!empty($attribute)) {
         $vdata->appendChild($this->createNode('Size', $attribute['attribute_name']));
     }
     if (isset($p->color) && !empty($p->color)) {
         $vdata->appendChild($this->createNode('Color', (string) $p->color));
     }
     $vdata->appendChild($this->createNode('VariationTheme', 'Size'));
     $cdata = $clothing->appendChild($this->createNode('ClassificationData'));
     $cdata->appendChild($this->createNode('ClothingType', 'Dress'));
     $cdata->appendChild($this->createNode('Department', 'womens'));
     if (isset($p->generic_color) && !empty($p->generic_color)) {
         $amazon_color = MarketplaceWebService_AmazonDataMap::getAmazonColor((string) $p->generic_color);
         if ($amazon_color !== null) {
             $cdata->appendChild($this->createNode('ColorMap', $amazon_color));
         }
     }
     if (isset($p->fabric) && !empty($p->fabric)) {
         $cdata->appendChild($this->createNode('MaterialAndFabric', (string) $p->fabric));
     }
     $cdata->appendChild($this->createNode('ModelNumber', $id_sku));
     if (!empty($attribute)) {
         $size = $attribute['attribute_name'];
         $amazon_size = MarketplaceWebService_AmazonDataMap::getAmazonSize($size);
         if ($amazon_size !== null) {
             $cdata->appendChild($this->createNode('SizeMap', $amazon_size));
         }
     }
     $wash_care = "Dry cleaning is the best method to wash";
     $cdata->appendChild($this->createNode('FabricWash', $wash_care));
     $cdata->appendChild($this->createNode('TargetGender', 'female'));
     //$wash_care = "Dry cleaning is the best method to wash an apparel made of soft and delicate material. Never wrap silk apparel in plastic and trap the moisture; this could change the color and quality of the fabric in no time.";
     return $product;
 }