vijayrami

php artisan ebay:importproducts

Jul 6th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 88.31 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Console\Commands;
  4.  
  5. use Illuminate\Console\Command;
  6.  
  7. use Illuminate\Support\Facades\DB;
  8.  
  9. use App\Ebay\EBaySessionProduct;
  10.  
  11. class EbayImportProducts extends Command
  12. {
  13.     /**
  14.      * The name and signature of the console command.
  15.      *
  16.      * @var string
  17.      */
  18.     protected $signature = 'ebay:importproducts';
  19.  
  20.     /**
  21.      * The console command description.
  22.      *
  23.      * @var string
  24.      */
  25.     protected $description = 'Import your Products into Ebay';
  26.    
  27.     const IMAGE_UPLOAD_STATUS = '5';
  28.    
  29.     const IMPORT_PRODUCT_NO_XML_RESPONSE_STATUS = '6';
  30.    
  31.     const IMPORT_PRODUCT_EBAY_ERROR_STATUS = '7';
  32.    
  33.     const EBAY_VERB = 'AddFixedPriceItem';
  34.  
  35.     const EBAY__REVISE_VERB = 'ReviseFixedPriceItem';
  36.    
  37.     const EBAY_CATEGORY_SPECIFIC_VERB = 'GetCategorySpecifics';
  38.    
  39.     const EBAY_CATEGORY_FEATURES_VERB = 'GetCategoryFeatures';
  40.    
  41.     /**
  42.      * Create a new command instance.
  43.      *
  44.      * @return void
  45.      */
  46.     public function __construct()
  47.     {
  48.         parent::__construct();
  49.     }
  50.     public function register()
  51.     {
  52.         $this->app->bind(
  53.             'EBaySessionProduct',
  54.             function () {
  55.                 return new EBaySessionProduct;
  56.             }
  57.         );
  58.     }
  59.    
  60.     /**
  61.      * Execute the console command.
  62.      *
  63.      * @return mixed
  64.      */
  65.     public function handle()
  66.     {
  67.         $variation_items =
  68.         $matrix =
  69.         $fee =
  70.         $feeName =
  71.         $fee_array =
  72.         $color_variations =
  73.         $color_variations_sort_arr = array();
  74.         $verb = EbayImportProducts::EBAY_VERB;
  75.         $verbRevise = EbayImportProducts::EBAY__REVISE_VERB;
  76.         $category_verb = EbayImportProducts::EBAY_CATEGORY_SPECIFIC_VERB;
  77.         $category_features_verb = EbayImportProducts::EBAY_CATEGORY_FEATURES_VERB;
  78.        
  79.         $devID = config('ebay.Dev_ID');
  80.         $appID = config('ebay.App_ID');
  81.         $certID = config('ebay.Cert_ID');
  82.         $comp_version = config('ebay.COMPATIBILITY_LEVEL');
  83.         $ebay_server_url = config('ebay.SERVER_URL');
  84.        
  85.         $getadmindata = DB::table('tbl_admin_ebay_setting')->first();
  86.         $import_designer_id = $getadmindata->ebay_designer_import_product_id;
  87.        
  88.         $import_products = DB::table('tbl_ebay_products')
  89.             ->join('tbl_magento_products', 'tbl_ebay_products.mage_pid', '=', 'tbl_magento_products.mp_pid')
  90.             ->join('tbl_products', 'tbl_ebay_products.magento_id', '=', 'tbl_products.mage_pid')
  91.             ->whereNull('tbl_ebay_products.cron_error')
  92.             ->select('tbl_ebay_products.*', 'tbl_magento_products.*', 'tbl_products.designer_id')
  93.             ->where([
  94.             ['tbl_products.processed_status', '=', 1],
  95.             ['tbl_products.for_ebay', '=', 1],
  96.             ['tbl_products.product_status', '=', '1'],
  97.             ['tbl_products.designer_id', '=', $import_designer_id]
  98.             ])
  99.             ->whereIn(
  100.                 'tbl_ebay_products.product_ebay_status',
  101.                 array(
  102.                 EbayImportProducts::IMAGE_UPLOAD_STATUS,
  103.                 EbayImportProducts::IMPORT_PRODUCT_NO_XML_RESPONSE_STATUS,
  104.                 EbayImportProducts::IMPORT_PRODUCT_EBAY_ERROR_STATUS
  105.                 )
  106.             )
  107.             ->offset(0)->limit(1)
  108.             ->groupBy('tbl_magento_products.mp_pid')
  109.             ->orderBy('tbl_magento_products.mp_pid', 'asc')
  110.             ->get();
  111.         //echo "<pre>";print_r($import_products);exit;
  112.         foreach ($import_products as $import_product) {
  113.             try {
  114.                 $designer_general_settings = \App\Designer::where(
  115.                     'designer_id',
  116.                     '=',
  117.                     $import_product->designer_id
  118.                 )->first();
  119.                 if ($designer_general_settings['is_ebay_shirtee_api_on'] == 1) {
  120.                     $cronName = \App\Constants::CRON_EBAY['IMPORT_PRODUCTS'];
  121.                       $cronExist = \App\CronDetail::where('cron_name', $cronName)->first();
  122.                     if ($cronExist) {
  123.                              $startDate = date('Y-m-d H:i:s');
  124.                     }
  125.                     $variation_items = (json_decode($import_product->mp_options));
  126.                     $import_product_data = (json_decode($import_product->mp_data));
  127.                     // Product Description
  128.                     if (!empty($import_product_data->description)
  129.                     && strlen($import_product_data->description) > 0
  130.                     && $import_product_data->description != '') {
  131.                         $product_description = $import_product_data->description;
  132.                     } else {
  133.                         $product_description = $import_product_data->short_description;
  134.                     }
  135.            
  136.                     $product_sku = $import_product->mp_sku;
  137.                     $sku_want = substr($product_sku, strpos($product_sku, "_") + 1);
  138.            
  139.                     $primary_category_id = \App\EbayBrowseData::where([
  140.                     ['sku', '=', $sku_want],
  141.                     ['language', '=', 4]
  142.                     ])->first();
  143.                     // Send mail and error log if category id not assigned
  144.                     if (empty($primary_category_id) && $primary_category_id == '') {
  145.                             $no_category_error = "Ebay Require that product assigned for atleast one category.
  146. But Below product have no category.
  147. please assign product's primary category from admin for below product ID: \n";
  148.                             $no_category_error .= "Product ID = $import_product->magento_id
  149. Product SKU = $import_product->mp_sku
  150. SKU in Browse Data Table = $sku_want";
  151.            
  152.                         \Mail::raw(
  153.                             $no_category_error,
  154.                             function ($message) {
  155.                                 $message->to('[email protected]')
  156.                                     ->bcc('[email protected]')
  157.                                     ->subject('Product Have No Primary Category - Ebay Import Product Error');
  158.                             }
  159.                         );
  160.                         \Log::channel('ebay')->error('This Product have no Primary Category : Product ID -'
  161.                          . $import_product->magento_id.' Product SKU = '.$import_product->mp_sku.'
  162.                          SKU in Browse node table = '.$sku_want);
  163.                         \App\EbayListProduct::where(
  164.                             'magento_id',
  165.                             $import_product->magento_id
  166.                         )->update(['cron_error' => '']);
  167.                         continue;
  168.                     }
  169.            
  170.                     $ebay_category_id = $primary_category_id->node1;
  171.            
  172.                     //echo "<pre>";print_r(count($variation_items[0]->additional_fields));exit;
  173.                     if (isset($variation_items[0]) && isset($variation_items[1])) {
  174.                         if ((count($variation_items[0]->additional_fields) > 0)
  175.                         && (count($variation_items[1]->additional_fields) > 0)) {
  176.                             $ebay_setting = \App\EbaySetting::where(
  177.                                 'designer_id',
  178.                                 '=',
  179.                                 $import_product->designer_id
  180.                             )->first();
  181.                             //echo "<pre>";print_r($ebay_setting);exit;
  182.                             if (isset($ebay_setting->max_dispatch_time)
  183.                             && $ebay_setting->max_dispatch_time != null
  184.                             && $ebay_setting->max_dispatch_time != '') {
  185.                                         $max_dispatch_time = $ebay_setting->max_dispatch_time;
  186.                             } else {
  187.                                      $max_dispatch_time = 7;
  188.                             }
  189.                    
  190.                             if (isset($ebay_setting->item_location)
  191.                             && $ebay_setting->item_location != null
  192.                             && $ebay_setting->item_location != '') {
  193.                                      $item_location = $ebay_setting->item_location;
  194.                             } else {
  195.                                                    $item_location = 'Köln';
  196.                             }
  197.                    
  198.                             if (isset($ebay_setting->item_postcode)
  199.                             && $ebay_setting->item_postcode != null
  200.                             && $ebay_setting->item_postcode != '') {
  201.                                 $item_postcode = $ebay_setting->item_postcode;
  202.                             } else {
  203.                                 $item_postcode = 50827;
  204.                             }
  205.                    
  206.                             if (isset($ebay_setting->item_postcode)
  207.                             && $ebay_setting->item_postcode != null
  208.                             && $ebay_setting->item_postcode != '') {
  209.                                 $item_postcode = $ebay_setting->item_postcode;
  210.                             } else {
  211.                                 $item_postcode = 50827;
  212.                             }
  213.                    
  214.                             if (isset($ebay_setting->brand_name)
  215.                             && $ebay_setting->brand_name != null
  216.                             && $ebay_setting->brand_name != '') {
  217.                                 $brand_name = $ebay_setting->brand_name;
  218.                             } else {
  219.                                 $brand_name = 'Shirtee';
  220.                             }
  221.                    
  222.                                        $siteID = $ebay_setting->ebay_site_id;
  223.                    
  224.                                        $paymentProfileLists = new \App\EbayPaymentPolicy;
  225.                                        $paymentProfileList = $paymentProfileLists->where(
  226.                                            'designer_id',
  227.                                            $import_product->designer_id
  228.                                        )->where('is_used', '=', 1)->first();
  229.                    
  230.                                        $returnProfileLists = new \App\EbayRetunPolicy;
  231.                                        $returnProfileList = $returnProfileLists->where(
  232.                                            'designer_id',
  233.                                            $import_product->designer_id
  234.                                        )->where('is_used', '=', 1)->first();
  235.                    
  236.                                        $shippingProfileLists = new \App\EbayShippingPolicy;
  237.                                        $shippingProfileList = $shippingProfileLists->where(
  238.                                            'designer_id',
  239.                                            $import_product->designer_id
  240.                                        )->where('is_used', '=', 1)->first();
  241.                    
  242.                                        //$ebayhelper = new \App\Helpers\EbayHelper();
  243.                                        //$ebaysettings = $ebayhelper->setEbaySettings($ebay_setting['0']->mode,$ebay_setting['0']->compatability_level,$ebay_setting['0']->paypal_email_address,$ebay_setting['0']->production_app_id,$ebay_setting['0']->production_dev_id,$ebay_setting['0']->production_cert_id,$ebay_setting['0']->production_user_tocken);
  244.                    
  245.                                        $ebaycategoryspecifics = $this->getCategorySpecifics(
  246.                                            $ebay_category_id,
  247.                                            $ebay_setting,
  248.                                            $siteID,
  249.                                            $category_verb
  250.                                        );
  251.                    
  252.                                        $ebayeanenabled = $this->getCategoryFeatures(
  253.                                            $ebay_category_id,
  254.                                            $ebay_setting,
  255.                                            $siteID,
  256.                                            $category_features_verb
  257.                                        );
  258.                                        ///Build the request Xml string
  259.                                        $dom = new \DOMDocument();
  260.  
  261.                                        $dom->encoding = 'utf-8';
  262.            
  263.                                        $dom->xmlVersion = '1.0';
  264.            
  265.                                        $dom->formatOutput = true;
  266.                    
  267.                             if ($import_product->product_ebay_id) {
  268.                                 $root = $dom->createElementNS(
  269.                                     'urn:ebay:apis:eBLBaseComponents',
  270.                                     'ReviseFixedPriceItemRequest'
  271.                                 );
  272.                             } else {
  273.                                 $root = $dom->createElementNS(
  274.                                     'urn:ebay:apis:eBLBaseComponents',
  275.                                     'AddFixedPriceItemRequest'
  276.                                 );
  277.                             }
  278.  
  279.                                        $request_node = $dom->createElement('RequesterCredentials');
  280.            
  281.                                        $ebay_auth = $dom->createElement(
  282.                                            'eBayAuthToken',
  283.                                            $ebay_setting->production_user_tocken
  284.                                        );
  285.            
  286.                                        $request_node->appendChild($ebay_auth);
  287.            
  288.                                        $root->appendChild($request_node);
  289.                    
  290.                                        $detail_node = $dom->createElement('DetailLevel', 'ReturnAll');
  291.                    
  292.                                        $root->appendChild($detail_node);
  293.                    
  294.                                        $err_lang_node = $dom->createElement('ErrorLanguage', 'en_US');
  295.                    
  296.                                        $root->appendChild($err_lang_node);
  297.                    
  298.                                        $war_level_node = $dom->createElement('WarningLevel', 'High');
  299.                    
  300.                                        $root->appendChild($war_level_node);
  301.                    
  302.                                        $ver_node = $dom->createElement('Version', $comp_version);
  303.                    
  304.                                        $root->appendChild($ver_node);
  305.                    
  306.                                        /* Item Node start*/
  307.                                        $item_node = $dom->createElement('Item');
  308.  
  309.                                        $itemId = $dom->createElement('ItemID', $import_product->product_ebay_id);
  310.            
  311.                                        $item_node->appendChild($itemId);
  312.            
  313.                                        $country = $dom->createElement('Country', $ebay_setting->ebay_country_code);
  314.            
  315.                                        $item_node->appendChild($country);
  316.                    
  317.                                        $currency = $dom->createElement('Currency', $ebay_setting->ebay_currency);
  318.            
  319.                                        $item_node->appendChild($currency);
  320.                    
  321.                                        $description = $dom->createElement('Description');
  322.                    
  323.                                        $description_cdata = $dom->createCDATASection(trim($product_description));
  324.                    
  325.                                        $description->appendChild($description_cdata);
  326.            
  327.                                        $item_node->appendChild($description);
  328.                    
  329.                                        $dispatch_time = $dom->createElement('DispatchTimeMax', $max_dispatch_time);
  330.            
  331.                                        $item_node->appendChild($dispatch_time);
  332.                    
  333.                                        $listing_duration = $dom->createElement('ListingDuration', 'GTC');
  334.            
  335.                                        $item_node->appendChild($listing_duration);
  336.                    
  337.                                        $listing_type = $dom->createElement('ListingType', 'FixedPriceItem');
  338.            
  339.                                        $item_node->appendChild($listing_type);
  340.                    
  341.                                        $location = $dom->createElement('Location', $item_location);
  342.            
  343.                                        $item_node->appendChild($location);
  344.                    
  345.                                        $paymentmethods1 = $dom->createElement('PaymentMethods', 'CashOnPickup');
  346.            
  347.                                        $item_node->appendChild($paymentmethods1);
  348.                    
  349.                             if (isset($ebay_setting->paypal_email_address)
  350.                             && $ebay_setting->paypal_email_address != null
  351.                             && $ebay_setting->paypal_email_address != '') {
  352.                                 $paymentmethods = $dom->createElement('PaymentMethods', 'PayPal');
  353.            
  354.                                 $item_node->appendChild($paymentmethods);
  355.                    
  356.                                 $paypal_email = $dom->createElement(
  357.                                     'PayPalEmailAddress',
  358.                                     $ebay_setting->paypal_email_address
  359.                                 );
  360.            
  361.                                 $item_node->appendChild($paypal_email);
  362.                             }
  363.                    
  364.                                        $post_code = $dom->createElement('PostalCode', $item_postcode);
  365.            
  366.                                        $item_node->appendChild($post_code);
  367.                    
  368.                                        $primary_category = $dom->createElement('PrimaryCategory');
  369.                    
  370.                                        $category_id = $dom->createElement('CategoryID', $ebay_category_id);
  371.            
  372.                                        $primary_category->appendChild($category_id);
  373.                    
  374.                                        $item_node->appendChild($primary_category);
  375.                    
  376.                                        /*$product_listing_details = $dom->createElement('ProductListingDetails');
  377.                                        $product_ean = $dom->createElement('EAN','6219595798795');
  378.                                        $product_listing_details->appendChild($product_ean);
  379.                                        $item_node->appendChild($product_listing_details);*/
  380.                                        /*$seller_profile = $dom->createElement('SellerProfiles');
  381.                                        $seller_payment_profile = $dom->createElement('SellerPaymentProfile');
  382.                                        $seller_profile->appendChild($seller_payment_profile);
  383.                                        $seller_payment_profile->appendChild($payment_profile_id);
  384.                                        $seller_payment_profile->appendChild($payment_profile_name);
  385.                                        $seller_return_profile = $dom->createElement('SellerReturnProfile');
  386.                                        $seller_profile->appendChild($seller_return_profile);
  387.                                        $seller_return_profile->appendChild($retun_profile_id);
  388.                                        $seller_return_profile->appendChild($return_profile_name);
  389.                                        $seller_shipping_profile = $dom->createElement('SellerShippingProfile');
  390.                                        $seller_profile->appendChild($seller_shipping_profile);
  391.                                        $seller_shipping_profile->appendChild($shipping_profile_id);
  392.                                        $seller_shipping_profile->appendChild($shipping_profile_name);
  393.                                        $item_node->appendChild($seller_profile);*/
  394.                    
  395.                                        $title = $dom->createElement(
  396.                                            'Title',
  397.                                            htmlspecialchars($import_product->mp_name)
  398.                                        );
  399.                                        $item_node->appendChild($title);
  400.                                        $condition = $dom->createElement('ConditionID', 1000);
  401.                                        $item_node->appendChild($condition);
  402.                                        //$pictures = $dom->createElement('PictureDetails');
  403.                                        $ebay_images_array = unserialize($import_product->ebay_image_urls);
  404.                                        $main_search_picture_details = $dom->createElement('PictureDetails');
  405.  
  406.                                        $picture_gallery_duration = $dom->createElement('GalleryDuration', 'Days_7');
  407.  
  408.                                        $main_search_picture_details->appendChild($picture_gallery_duration);
  409.  
  410.                                        $picture_gallery_type = $dom->createElement('GalleryType', 'Gallery');
  411.  
  412.                                        $main_search_picture_details->appendChild($picture_gallery_type);
  413.  
  414.                                        $picture_photo_display = $dom->createElement('PhotoDisplay', 'SuperSize');
  415.  
  416.                                        $main_search_picture_details->appendChild($picture_photo_display);
  417.  
  418.                                        $picture_source = $dom->createElement('PictureSource', 'EPS');
  419.  
  420.                                        $main_search_picture_details->appendChild($picture_source);
  421.  
  422.                                        $picture_search_url = $dom->createElement(
  423.                                            'PictureURL',
  424.                                            $ebay_images_array['0']['0']
  425.                                        );
  426.  
  427.                                        $main_search_picture_details->appendChild($picture_search_url);
  428.            
  429.                                        $item_node->appendChild($main_search_picture_details);
  430.                                        /*for ($i = 0; $i < $length; $i++) {
  431.                                        $picture_url = $dom->createElement('PictureURL', $ebay_images_array[$i]['0']);
  432.                                        $pictures->appendChild($picture_url);
  433.                                        }
  434.                                        $item_node->appendChild($pictures);*/
  435.                                        $returnpolicy = $dom->createElement('ReturnPolicy');
  436.                    
  437.                                        //$refundoption = $dom->createElement('RefundOption','MoneyBack');
  438.                    
  439.                                        $returns_accepted_option = $dom->createElement(
  440.                                            'ReturnsAcceptedOption',
  441.                                            'ReturnsAccepted'
  442.                                        );
  443.                    
  444.                                        $returns_within_option = $dom->createElement('ReturnsWithinOption', 'Days_30');
  445.                    
  446.                                        $shipping_cost_paid = $dom->createElement('ShippingCostPaidByOption', 'Seller');
  447.                    
  448.                                        //$returnpolicy->appendChild($refundoption);
  449.                    
  450.                                        $returnpolicy->appendChild($returns_accepted_option);
  451.                    
  452.                                        $returnpolicy->appendChild($returns_within_option);
  453.                    
  454.                                        $returnpolicy->appendChild($shipping_cost_paid);
  455.            
  456.                                        $item_node->appendChild($returnpolicy);
  457.                    
  458.                                        $shippingdetails = $dom->createElement('ShippingDetails');
  459.                    
  460.                                        /*$salestax = $dom->createElement('SalesTax');
  461.                                        $salestax_per = $dom->createElement('SalesTaxPercent','8.5');
  462.                                        $salestaxstate = $dom->createElement('SalesTaxState','CA');
  463.                                        $salestax->appendChild($salestax_per);
  464.                                        $salestax->appendChild($salestaxstate);
  465.                                        $shippingdetails->appendChild($salestax);*/
  466.                                        $shippingtype = $dom->createElement('ShippingType', 'Flat');
  467.                    
  468.                                        $shippingdetails->appendChild($shippingtype);
  469.                    
  470.                                        $shippingserviceoptions = $dom->createElement('ShippingServiceOptions');
  471.                    
  472.                                        $shippingservicepriority = $dom->createElement('ShippingServicePriority', '1');
  473.                    
  474.                                        $shippingservice = $dom->createElement('ShippingService', 'DE_DHLPaket');
  475.                    
  476.                                        $shippingservicecost = $dom->createElement('ShippingServiceCost', '0.0');
  477.                    
  478.                                        $attr_cost_currency = new \DOMAttr('currencyID', $ebay_setting->ebay_currency);
  479.                    
  480.                                        $shippingservicecost->setAttributeNode($attr_cost_currency);
  481.                    
  482.                                        $shippingServiceadditionalcost = $dom->createElement(
  483.                                            'ShippingServiceAdditionalCost',
  484.                                            '0.0'
  485.                                        );
  486.                    
  487.                                        $attr_additional_cost_currency = new \DOMAttr(
  488.                                            'currencyID',
  489.                                            $ebay_setting->ebay_currency
  490.                                        );
  491.                    
  492.                                        $shippingServiceadditionalcost->setAttributeNode($attr_additional_cost_currency);
  493.                    
  494.                                        //$expeditedservice = $dom->createElement('ExpeditedService','false');
  495.                    
  496.                                        //$shippingtimemin = $dom->createElement('ShippingTimeMin','1');
  497.                    
  498.                                        //$shippingtimemax = $dom->createElement('ShippingTimeMax','2');
  499.                    
  500.                                        $freeshipping = $dom->createElement('FreeShipping', 'true');
  501.                    
  502.                                        $shippingserviceoptions->appendChild($shippingservicepriority);
  503.                    
  504.                                        $shippingserviceoptions->appendChild($shippingservice);
  505.                    
  506.                                        $shippingserviceoptions->appendChild($shippingservicecost);
  507.                    
  508.                                        $shippingserviceoptions->appendChild($shippingServiceadditionalcost);
  509.                    
  510.                                        //$shippingserviceoptions->appendChild($expeditedservice);
  511.                    
  512.                                        //$shippingserviceoptions->appendChild($shippingtimemin);
  513.                    
  514.                                        //$shippingserviceoptions->appendChild($shippingtimemax);
  515.                    
  516.                                        $shippingserviceoptions->appendChild($freeshipping);
  517.                    
  518.                                        $shippingdetails->appendChild($shippingserviceoptions);
  519.                    
  520.                                        $item_node->appendChild($shippingdetails);
  521.                    
  522.                    
  523.                                        $itemspecifics = $dom->createElement('ItemSpecifics');
  524.                             if (count($ebaycategoryspecifics) > 0) {
  525.                                 for ($i = 0; $i < count($ebaycategoryspecifics); $i++) {
  526.                                     if ($ebaycategoryspecifics[$i]['Name'] == 'Marke'
  527.                                     && $ebaycategoryspecifics[$i]['ValidationRules']['SelectionMode'] == 'FreeText') {
  528.                                         $namevaluelist = $dom->createElement('NameValueList');
  529.                                         $name = $dom->createElement('Name', 'Marke');
  530.                                         $value = $dom->createElement('Value', $brand_name);
  531.                            
  532.                                         $itemspecifics->appendChild(
  533.                                             $namevaluelist
  534.                                         );
  535.                            
  536.                                                                                           $namevaluelist->appendChild(
  537.                                                                                               $name
  538.                                                                                           );
  539.                            
  540.                                                                                           $namevaluelist->appendChild(
  541.                                                                                               $value
  542.                                                                                           );
  543.                                     } elseif ($ebaycategoryspecifics[$i]['Name'] == 'Größe'
  544.                                     && $ebaycategoryspecifics[$i]['ValidationRules']['SelectionMode'] == 'FreeText') {
  545.                                                                         $namevaluelist = $dom->createElement(
  546.                                                                             'NameValueList'
  547.                                                                         );
  548.                    
  549.                                                                         $name = $dom->createElement('Name', 'Größe');
  550.                            
  551.                                                                         $value = $dom->createElement('Value', 'S');
  552.                            
  553.                                                                         $itemspecifics->appendChild($namevaluelist);
  554.                            
  555.                                                                         $namevaluelist->appendChild($name);
  556.                            
  557.                                                                         $namevaluelist->appendChild($value);
  558.                                     } else {
  559.                                                          $namevaluelist = $dom->createElement('NameValueList');
  560.                    
  561.                                                          $name = $dom->createElement(
  562.                                                              'Name',
  563.                                                              $ebaycategoryspecifics[$i]['Name']
  564.                                                          );
  565.                            
  566.                                         if (isset($ebaycategoryspecifics[$i]['ValueRecommendation']['0']['Value'])) {
  567.                                             $value = $dom->createElement(
  568.                                                 'Value',
  569.                                                 $ebaycategoryspecifics[$i]['ValueRecommendation']['0']['Value']
  570.                                             );
  571.                                         } else {
  572.                                               $value = $dom->createElement(
  573.                                                   'Value',
  574.                                                   $ebaycategoryspecifics[$i]['ValueRecommendation']['Value']
  575.                                               );
  576.                                         }
  577.                                             $itemspecifics->appendChild($namevaluelist);
  578.                            
  579.                                             $namevaluelist->appendChild($name);
  580.                            
  581.                                             $namevaluelist->appendChild($value);
  582.                                     }
  583.                                 }
  584.                             }
  585.                                        /*$namevaluelist1 = $dom->createElement('NameValueList');
  586.                                        $name1 = $dom->createElement('Name','Occasion');
  587.                                        $value1 = $dom->createElement('Value','Special');
  588.                                        $itemspecifics->appendChild($namevaluelist1);
  589.                                        $namevaluelist1->appendChild($name1);
  590.                                        $namevaluelist1->appendChild($value1);
  591.                                        $namevaluelist2 = $dom->createElement('NameValueList');
  592.                                        $name2 = $dom->createElement('Name','Brand');
  593.                                        $value2 = $dom->createElement('Value','Shirtee');
  594.                                        $itemspecifics->appendChild($namevaluelist2);
  595.                                        $namevaluelist2->appendChild($name2);
  596.                                        $namevaluelist2->appendChild($value2);
  597.                                        $namevaluelist3 = $dom->createElement('NameValueList');
  598.                                        $name3 = $dom->createElement('Name','Size Type');
  599.                                        $value3 = $dom->createElement('Value','Regular');
  600.                                        $itemspecifics->appendChild($namevaluelist3);
  601.                                        $namevaluelist3->appendChild($name3);
  602.                                        $namevaluelist3->appendChild($value3);
  603.                                        $namevaluelist4 = $dom->createElement('NameValueList');
  604.                                        $name4 = $dom->createElement('Name','Größe');
  605.                                        $value4 = $dom->createElement('Value','S');
  606.                                        $itemspecifics->appendChild($namevaluelist4);
  607.                                        $namevaluelist4->appendChild($name4);
  608.                                        $namevaluelist4->appendChild($value4);
  609.                                        $namevaluelist5 = $dom->createElement('NameValueList');
  610.                                        $name5 = $dom->createElement('Name','Style');
  611.                                        $value5 = $dom->createElement('Value','Polo Shirt');
  612.                                        $itemspecifics->appendChild($namevaluelist5);
  613.                                        $namevaluelist5->appendChild($name5);
  614.                                        $namevaluelist5->appendChild($value5);
  615.                                        $namevaluelist6 = $dom->createElement('NameValueList');
  616.                                        $name6 = $dom->createElement('Name','Sleeve Style');
  617.                                        $value6 = $dom->createElement('Value','Short Sleeve');
  618.                                        $itemspecifics->appendChild($namevaluelist6);
  619.                                        $namevaluelist6->appendChild($name6);
  620.                                        $namevaluelist6->appendChild($value6);
  621.                                        $namevaluelist7 = $dom->createElement('NameValueList');
  622.                                        $name7 = $dom->createElement('Name',"Bottoms Size (Men's)");
  623.                                        $value7 = $dom->createElement('Value','S');
  624.                                        $itemspecifics->appendChild($namevaluelist7);
  625.                                        $namevaluelist7->appendChild($name7);
  626.                                        $namevaluelist7->appendChild($value7);*/
  627.                                        $item_node->appendChild($itemspecifics);
  628.                    
  629.                                        $variations = $dom->createElement('Variations');
  630.                    
  631.                                        $variationspecificsset = $dom->createElement('VariationSpecificsSet');
  632.                    
  633.                                        $options_array = json_decode($import_product->mp_options);
  634.                                        $option_length = count(json_decode($import_product->mp_options));
  635.                    
  636.                             for ($op = 0; $op < $option_length; $op++) {
  637.                                 $option_namevaluelist = $dom->createElement('NameValueList');
  638.                                 $option_name = $dom->createElement('Name', $options_array[$op]->title);
  639.                                 $option_namevaluelist->appendChild($option_name);
  640.                                 for ($opv=0; $opv < count($options_array[$op]->additional_fields); $opv++) {
  641.                                     $option_value = $dom->createElement(
  642.                                         'Value',
  643.                                         $options_array[$op]->additional_fields[$opv]->title
  644.                                     );
  645.                                     $option_namevaluelist->appendChild($option_value);
  646.                                 }
  647.                                            $variationspecificsset->appendChild($option_namevaluelist);
  648.                             }
  649.                    
  650.                                        $variations->appendChild($variationspecificsset);
  651.                    
  652.                                        $ad1_json = $variation_items[0];
  653.                                        $ad2_json = $variation_items[1];
  654.                                        $ad1_array = $variation_items[0]->additional_fields;
  655.                                        $ad2_array = $variation_items[1]->additional_fields;
  656.                                        $ad1_length = count($ad1_array);
  657.                                        $ad2_length = count($ad2_array);
  658.                                        // custom code start
  659.                                        //echo "<pre>";print_r($ad1_array);echo "<br/>";print_r($ad2_array);exit;
  660.                             if ($ad2_length > $ad1_length) {
  661.                                 $ad1_array = $variation_items[1]->additional_fields;
  662.                                 $ad2_array = $variation_items[0]->additional_fields;
  663.                                 $ad1_json = $variation_items[1];
  664.                                 $ad2_json = $variation_items[0];
  665.                                 $ad1_length = count($ad1_array);
  666.                                 $ad2_length = count($ad2_array);
  667.                             }
  668.                    
  669.                                        $new_ad1_array = $new_array1 = $new_ad2_array = $new_array2 = array();
  670.                             foreach ($ad1_array as $ad1_array_key => $ad1_array_value) {
  671.                                 $new_ad1_array[] =  (array) $ad1_array_value;
  672.                             }
  673.                             foreach ($new_ad1_array as $new_ad1_array_key => $new_ad1_array_value) {
  674.                                 $new_ad1_array_value["option_name"] = $ad1_json->title;
  675.                                 $new_array1[] = $new_ad1_array_value;
  676.                             }
  677.                    
  678.                             foreach ($ad2_array as $ad2_array_key => $ad2_array_value) {
  679.                                 $new_ad2_array[] =  (array) $ad2_array_value;
  680.                             }
  681.                             foreach ($new_ad2_array as $new_ad2_array_key => $new_ad2_array_value) {
  682.                                 $new_ad2_array_value["option_name"] = $ad2_json->title;
  683.                                 $new_array2[] = $new_ad2_array_value;
  684.                             }
  685.                    
  686.                                        // custom code Ends
  687.                                        $new_array1 = $this->arrayMsort($new_array1, array('value_id'=>SORT_ASC));
  688.                                        $new_array2 = $this->arrayMsort($new_array2, array('value_id'=>SORT_ASC));
  689.                                        $ad1_array = json_decode(json_encode($ad1_array), true);
  690.                                        $ad2_array = json_decode(json_encode($ad2_array), true);
  691.                                        $ad1_array = $this->arrayMsort($ad1_array, array('value_id'=>SORT_ASC));
  692.                                        $ad2_array = $this->arrayMsort($ad2_array, array('value_id'=>SORT_ASC));
  693.                                        //echo "<pre>";print_r((array)$ad1_array);
  694.                                        //echo "<br/>";print_r((array)$ad2_array);exit;
  695.                                        $valid3xl = array("16", "4", "198", "17");
  696.                                        $valid4xl = array("16", "4", "198", "17");
  697.                                        $valid_jh030_3xl = array("1624", "668", "1676", "1565", "839", "31");
  698.                                        $valid_jh001_3xl = array("1624", "668", "1698");
  699.                                        $valid_jh001_4xl = array("1624", "1698");
  700.                                        $valid_jh001_5xl = array("1624", "1698");
  701.                                        $valid_jh001_xs = array("3", "16");
  702.                                        $valid_bctk301 = array("1151", "1236");
  703.                                        $valid_swgl = array("3468");
  704.                                        $valid_a88vl = array("2462");
  705.                                        $valid_a88vl_xxl = array("1610");
  706.                             for ($ad1 = 0; $ad1 < $ad1_length; $ad1++) {
  707.                                 for ($ad2 = 0; $ad2 < $ad2_length; $ad2++) {
  708.                                     // start for JH030
  709.                                     if ($sku_want == 'JH030'
  710.                                     && $new_array2[$ad2]['sku'] == '3XL'
  711.                                     && !in_array($new_array1[$ad1]['sku'], $valid_jh030_3xl)) {
  712.                                                                                                    continue;
  713.                                     }
  714.                                     if ($sku_want == 'JH030'
  715.                                     && $new_array1[$ad1]['sku'] == '3XL'
  716.                                     && !in_array($new_array2[$ad2]['sku'], $valid_jh030_3xl)) {
  717.                                                                                                    continue;
  718.                                     }
  719.                                     // end for JH030
  720.                                     // start for BCTU004
  721.                                     if ($sku_want == 'BCTU004'
  722.                                     && $new_array2[$ad2]['sku'] == '3XL'
  723.                                     && !in_array($new_array1[$ad1]['sku'], $valid3xl)) {
  724.                                         continue;
  725.                                     }
  726.                                     if ($sku_want == 'BCTU004'
  727.                                     && $new_array1[$ad1]['sku'] == '3XL'
  728.                                     && !in_array($new_array2[$ad2]['sku'], $valid3xl)) {
  729.                                         continue;
  730.                                     }
  731.                                     if ($sku_want == 'BCTU004'
  732.                                     && $new_array2[$ad2]['sku'] == '4XL'
  733.                                     && !in_array($new_array1[$ad1]['sku'], $valid4xl)) {
  734.                                         continue;
  735.                                     }
  736.                                     if ($sku_want == 'BCTU004'
  737.                                     && $new_array1[$ad1]['sku'] == '4XL'
  738.                                     && !in_array($new_array2[$ad2]['sku'], $valid4xl)) {
  739.                                         continue;
  740.                                     }
  741.                                     // End for BCTU004
  742.                                     // start for JH001
  743.                                     if ($sku_want == 'JH001'
  744.                                     && $new_array2[$ad2]['sku'] == '3XL'
  745.                                     && !in_array($new_array1[$ad1]['sku'], $valid_jh001_3xl)) {
  746.                                                                                                continue;
  747.                                     }
  748.                                     if ($sku_want == 'JH001'
  749.                                     && $new_array1[$ad1]['sku'] == '3XL'
  750.                                     && !in_array($new_array2[$ad2]['sku'], $valid_jh001_3xl)) {
  751.                                                                                        continue;
  752.                                     }
  753.                                     if ($sku_want == 'JH001'
  754.                                     && $new_array2[$ad2]['sku'] == '4XL'
  755.                                     && !in_array($new_array1[$ad1]['sku'], $valid_jh001_4xl)) {
  756.                                                                                     continue;
  757.                                     }
  758.                                     if ($sku_want == 'JH001'
  759.                                     && $new_array1[$ad1]['sku'] == '4XL'
  760.                                     && !in_array($new_array2[$ad2]['sku'], $valid_jh001_4xl)) {
  761.                                                                                      continue;
  762.                                     }
  763.                                     if ($sku_want == 'JH001'
  764.                                     && $new_array2[$ad2]['sku'] == '5XL'
  765.                                     && !in_array($new_array1[$ad1]['sku'], $valid_jh001_5xl)) {
  766.                                                                                continue;
  767.                                     }
  768.                                     if ($sku_want == 'JH001'
  769.                                     && $new_array1[$ad1]['sku'] == '5XL'
  770.                                     && !in_array($new_array2[$ad2]['sku'], $valid_jh001_5xl)) {
  771.                                                                          continue;
  772.                                     }
  773.                                     if ($sku_want == 'JH001'
  774.                                     && $new_array2[$ad2]['sku'] == 'XS'
  775.                                     && !in_array($new_array1[$ad1]['sku'], $valid_jh001_xs)) {
  776.                                                                    continue;
  777.                                     }
  778.                                     if ($sku_want == 'JH001'
  779.                                     && $new_array1[$ad1]['sku'] == 'XS'
  780.                                     && !in_array($new_array2[$ad2]['sku'], $valid_jh001_xs)) {
  781.                                                              continue;
  782.                                     }
  783.                                     // end for JH001
  784.                                     // start for BCTK301
  785.                                     if ($sku_want == 'BCTK301'
  786.                                     && in_array($new_array1[$ad1]['sku'], $valid_bctk301)) {
  787.                                                        continue;
  788.                                     }
  789.                                     if ($sku_want == 'BCTK301' && in_array($new_array2[$ad2]['sku'], $valid_bctk301)) {
  790.                                                    continue;
  791.                                     }
  792.                                     // end for BCTK301
  793.                                     // start for SWGL1,SWGL2,A88VL
  794.                                     if ($sku_want == 'SWGL1' && in_array($new_array1[$ad1]['sku'], $valid_swgl)) {
  795.                                                continue;
  796.                                     }
  797.                                     if ($sku_want == 'SWGL1' && in_array($new_array2[$ad2]['sku'], $valid_swgl)) {
  798.                                            continue;
  799.                                     }
  800.                                     if ($sku_want == 'SWGL2' && in_array($new_array1[$ad1]['sku'], $valid_swgl)) {
  801.                                                           continue;
  802.                                     }
  803.                                     if ($sku_want == 'SWGL2' && in_array($new_array2[$ad2]['sku'], $valid_swgl)) {
  804.                                                           continue;
  805.                                     }
  806.                                     if ($sku_want == 'A88VL' && in_array($new_array1[$ad1]['sku'], $valid_a88vl)) {
  807.                                                       continue;
  808.                                     }
  809.                                     if ($sku_want == 'A88VL' && in_array($new_array2[$ad2]['sku'], $valid_a88vl)) {
  810.                                                   continue;
  811.                                     }
  812.                                     // end for SWGL1,SWGL2,A88VL
  813.                                     // start for A88VL XXL
  814.                                     if ($sku_want == 'A88VL'
  815.                                     && $new_array2[$ad2]['sku'] == 'XXL'
  816.                                     && in_array($new_array1[$ad1]['sku'], $valid_a88vl_xxl)) {
  817.                                                                                                    continue;
  818.                                     }
  819.                                     if ($sku_want == 'A88VL'
  820.                                     && $new_array1[$ad1]['sku'] == 'XXL'
  821.                                     && in_array($new_array2[$ad2]['sku'], $valid_a88vl_xxl)) {
  822.                                                                                                    continue;
  823.                                     }
  824.                                     // End for A88VL XXL
  825.                                     $variation = $dom->createElement('Variation');
  826.                              
  827.                                     $sku = $dom->createElement('SKU', $import_product->mp_sku.
  828.                                     "__".$new_array1[$ad1]['sku']."__".$new_array2[$ad2]['sku']);
  829.                                     $price_cal = number_format($ad1_array[$ad1]['price'] +$ad2_array[$ad2]['price'], 2);
  830.                                     if ($price_cal == 0.00) {
  831.                                               $price_cal = number_format(1, 2);
  832.                                     }
  833.                                     $startprice = $dom->createElement('StartPrice', $import_product_data->price);
  834.                                     $quantity = $dom->createElement('Quantity', '1');
  835.                            
  836.                                     $variationproductlistingdetails = $dom->createElement(
  837.                                         'VariationProductListingDetails'
  838.                                     );
  839.                                     if (isset($ebayeanenabled['Category']['EANEnabled'])
  840.                                     && $ebayeanenabled['Category']['EANEnabled'] == 'Required') {
  841.                                             $fake_country = $this->getRandomEAN(2); // generate 13 length random number
  842.                                             $fake_country_code = '2'.$fake_country;
  843.                                             $random_ean_ebay = $this->generateEAN(13, $fake_country_code);
  844.                                             $variationproductlistingdetails_ean = $dom->createElement(
  845.                                                 'EAN',
  846.                                                 $random_ean_ebay
  847.                                             );
  848.                                             $variationproductlistingdetails->appendChild(
  849.                                                 $variationproductlistingdetails_ean
  850.                                             );
  851.                                     }
  852.                            
  853.                            
  854.                                     $ad_variationspecifics = $dom->createElement('VariationSpecifics');
  855.                                     $ad1_namevaluelist = $dom->createElement('NameValueList');
  856.                                     $ad1_name = $dom->createElement('Name', $new_array1[$ad1]['option_name']);
  857.                                     $ad1_value = $dom->createElement('Value', $new_array1[$ad1]['title']);
  858.                                     $ad1_namevaluelist->appendChild($ad1_name);
  859.                                     $ad1_namevaluelist->appendChild($ad1_value);
  860.                                     $ad_variationspecifics->appendChild($ad1_namevaluelist);
  861.                            
  862.                                     $ad2_namevaluelist = $dom->createElement('NameValueList');
  863.                                     $ad2_name = $dom->createElement('Name', $new_array2[$ad2]['option_name']);
  864.                                     $ad2_value = $dom->createElement('Value', $new_array2[$ad2]['title']);
  865.                                     $ad2_namevaluelist->appendChild($ad2_name);
  866.                                     $ad2_namevaluelist->appendChild($ad2_value);
  867.                                     $ad_variationspecifics->appendChild($ad2_namevaluelist);
  868.                            
  869.                                     $variation->appendChild($sku);
  870.                                     $variation->appendChild($startprice);
  871.                                     $variation->appendChild($quantity);
  872.                                     $variation->appendChild($variationproductlistingdetails);
  873.                                     $variation->appendChild($ad_variationspecifics);
  874.                                     $variations->appendChild($variation);
  875.                                 }
  876.                             }
  877.                                        $picture_variation = $dom->createElement('Pictures');
  878.                                        $picture_variation_name = $dom->createElement('VariationSpecificName', 'color');
  879.                                        $picture_variation->appendChild($picture_variation_name);
  880.                                        $variations->appendChild($picture_variation);
  881.                                        //echo "<pre>";print_r($variation_items[1]->additional_fields);exit;
  882.                                        $color_variations = json_decode(
  883.                                            json_encode($variation_items[1]->additional_fields),
  884.                                            true
  885.                                        );
  886.                                        $color_variations = $this->arrayMsort(
  887.                                            $color_variations,
  888.                                            array('value_id'=>SORT_ASC)
  889.                                        );
  890.                                        //echo "<pre>";print_r($color_variations);exit;
  891.                             foreach ($color_variations as $color_variation) {
  892.                                 $value_ids[] = $color_variation['value_id'];
  893.                             }
  894.                    
  895.                             foreach ($value_ids as $value_id) {
  896.                                 foreach ($ebay_images_array as $images_array) {
  897.                                     if ($value_id == $images_array['1']) {
  898.                                         $color_images[]=$images_array['0'];
  899.                                     }
  900.                                 }
  901.                             }
  902.                                        //echo "<pre>";print_r(array_values($color_variations));exit;
  903.                                        $color_variations_sort_arr = array_values($color_variations);
  904.                             for ($var_pic = 0; $var_pic < count($color_variations_sort_arr); $var_pic++) {
  905.                                 $variation_specific_pic_set = $dom->createElement('VariationSpecificPictureSet');
  906.                                 $variation_specific_pic_val = $dom->createElement(
  907.                                     'VariationSpecificValue',
  908.                                     $color_variations_sort_arr[$var_pic]['title']
  909.                                 );
  910.                                 $variation_pic_url = $dom->createElement('PictureURL', $color_images[$var_pic]);
  911.                        
  912.                                 $variation_specific_pic_set->appendChild($variation_specific_pic_val);
  913.                                 $variation_specific_pic_set->appendChild($variation_pic_url);
  914.                                 if ($var_pic == count($color_variations_sort_arr)-1) {
  915.                                     $measurementImage = $this->getMeasurementImage($sku_want, 4);
  916.                                     $image_path = url('/');
  917.                                     $measurementImageUrl = $image_path.'/browsenode/measurementimage/'
  918.                                     .$measurementImage;
  919.                                     if (!empty($measurementImage) && $measurementImage != '') {
  920.                                         $ebaybrowsenodeimages = $this->getBrowseNodeImagesEbay(
  921.                                             $ebay_setting,
  922.                                             $siteID,
  923.                                             $measurementImageUrl
  924.                                         );
  925.                                     }
  926.                                     //echo "<pre>";print_r($ebaybrowsenodeimages);exit;
  927.                                     if (count($ebaybrowsenodeimages) > 0) {
  928.                                         for ($siz_pic = 0; $siz_pic < count($ebaybrowsenodeimages); $siz_pic++) {
  929.                                             $variation_size_url = $dom->createElement(
  930.                                                 'PictureURL',
  931.                                                 $ebaybrowsenodeimages[$siz_pic]
  932.                                             );
  933.                                             $variation_specific_pic_set->appendChild($variation_size_url);
  934.                                         }
  935.                                     }
  936.                                     /*$ebay_browse_images = \App\EbayBrowseMeasurementImage::where(
  937.                                         'browse_data_id',
  938.                                         '=',
  939.                                         $primary_category_id->id
  940.                                     )->get();
  941.                                     if (count($ebay_browse_images) > 0) {
  942.                                         for ($siz_pic = 0; $siz_pic < count($ebay_browse_images); $siz_pic++) {
  943.                                             $variation_size_url = $dom->createElement(
  944.                                                 'PictureURL',
  945.                                                 $ebay_browse_images[$siz_pic]->ebay_measurement_image_url
  946.                                             );
  947.                                             $variation_specific_pic_set->appendChild($variation_size_url);
  948.                                         }
  949.                                     }*/
  950.                                 }
  951.                                            $picture_variation->appendChild($variation_specific_pic_set);
  952.                             }
  953.                    
  954.                                        $item_node->appendChild($variations);
  955.                                        $site_country_node = $dom->createElement('Site', $ebay_setting->ebay_site_name);
  956.                                        $item_node->appendChild($site_country_node);
  957.                    
  958.                                        // ItemSpecifics to specify Item start
  959.                    
  960.                                        // ItemSpecifics to specify Item ends
  961.                    
  962.                                        $root->appendChild($item_node);
  963.                    
  964.                                        /* Item Node Ends*/
  965.                
  966.                                        $dom->appendChild($root);
  967.                    
  968.                                        $xml = $dom->saveXML();
  969.                                        //echo $xml;exit;
  970.  
  971.                             if ($import_product->product_ebay_id) {
  972.                                 $verb = $verbRevise;
  973.                             }
  974.  
  975.                                        $ebay_session_product = new \EBaySessionProduct(
  976.                                            $ebay_setting->production_user_tocken,
  977.                                            $devID,
  978.                                            $appID,
  979.                                            $certID,
  980.                                            $ebay_server_url,
  981.                                            $comp_version,
  982.                                            $siteID,
  983.                                            $verb
  984.                                        );
  985.                    
  986.                                        $responseXml = $ebay_session_product->sendHttpRequest($xml);
  987.                                        //echo "<pre>";print_r($responseXml);echo "</pre>";exit;
  988.                             if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
  989.                                 DB::table('tbl_ebay_products')->where(
  990.                                     'magento_id',
  991.                                     $import_product->magento_id
  992.                                 )->update(['product_ebay_status' => '6'], ['cron_error' => '']);
  993.                                 $no_response_error = "There is some Error in Ebays Trading API AddFixedPriceItem call.
  994. For Below product: \n";
  995.                                 $no_response_error .= "Product ID = ".$import_product->magento_id."
  996.                                 Product SKU = ".$import_product->mp_sku;
  997.            
  998.                                 \Mail::raw(
  999.                                     $no_response_error,
  1000.                                     function ($message) {
  1001.                                             $message->to('[email protected]')
  1002.                                                 ->bcc('[email protected]')
  1003.                                                 ->subject('No Response From Ebay - Ebay Import Product Error');
  1004.                                     }
  1005.                                 );
  1006.                                 \Log::channel('ebay')->info('There is some Error in Ebays Trading API
  1007.                                AddFixedPriceItem call.
  1008.                                For Product Magento id - '.$import_product->magento_id.' Product sku - '
  1009.                                 .$import_product->mp_sku.' Please wait for sometime and try again.');
  1010.                             } else {
  1011.                                 $responseDoc = new \DomDocument();
  1012.                                 $responseDoc->loadXML($responseXml);
  1013.                                 $errorsnodes = $responseDoc->getElementsByTagName('Errors');
  1014.                        
  1015.                                 foreach ($errorsnodes as $errorsnode) {
  1016.                                     $errorNames = $errorsnode->getElementsByTagName("SeverityCode");
  1017.                                     if ($errorNames->item('0')->nodeValue == "Error") {
  1018.                                                                       $errorDB[] = $errorsnode->getElementsByTagName(
  1019.                                                                           "ErrorCode"
  1020.                                                                       )->item('0')->nodeValue;
  1021.                                            $replshortmsg = str_replace(
  1022.                                                "<",
  1023.                                                "&lt;",
  1024.                                                $errorsnode->getElementsByTagName(
  1025.                                                    'ShortMessage'
  1026.                                                )->item(0)->nodeValue
  1027.                                            );                  $shortMsgDB[] =
  1028.                                            str_replace(">", "&gt;", $replshortmsg);
  1029.                                         $longMsgDB[] = str_replace(
  1030.                                             ">",
  1031.                                             "&gt;",
  1032.                                             str_replace(
  1033.                                                 "<",
  1034.                                                 "&lt;",
  1035.                                                 $errorsnode->getElementsByTagName('LongMessage')->item(0)->nodeValue
  1036.                                             )
  1037.                                         );
  1038.                                     }
  1039.                                 } // foreach $feeNode
  1040.                                 if ((isset($errorDB)
  1041.                                 && (count($errorDB) > 0))
  1042.                                 && (isset($shortMsgDB)
  1043.                                 && (count($shortMsgDB) > 0))
  1044.                                 && (isset($longMsgDB)
  1045.                                 && (count($longMsgDB) > 0))) {
  1046.                                     DB::table('tbl_ebay_products')->where(
  1047.                                         'magento_id',
  1048.                                         $import_product->magento_id
  1049.                                     )->update([
  1050.                                         'product_ebay_status' => '7',
  1051.                                         'error' => 'Error',
  1052.                                         'error_code'=>serialize($errorDB),
  1053.                                         'error_short_msg'=>serialize($shortMsgDB),
  1054.                                         'error_long_msg'=>serialize($longMsgDB),
  1055.                                         'cron_error'=> ''
  1056.                                         ]);
  1057.                                     //$code_link = "https://developer.ebay.com/devzone/xml/docs/Reference/ebay/Errors/errormessages.htm#".$codeDB;
  1058.                                     //echo "\033[0;31mError: There is some error in Ebay's Product import script.";
  1059.                                     $script_error = "There is some Error in Ebays Product import script.
  1060. For Below product: \n";
  1061.                                     $script_error .= "Product ID = ".$import_product->magento_id."
  1062. Product SKU = ".$import_product->mp_sku;
  1063.            
  1064.                                     \Mail::raw(
  1065.                                         $script_error,
  1066.                                         function ($message) {
  1067.                                                      $message->to('[email protected]')
  1068.                                                          ->bcc('[email protected]')
  1069.                                                          ->subject('Ebay Product import script Error');
  1070.                                         }
  1071.                                     );
  1072.                                     \Log::channel('ebay')->info('There is some Error in Ebays Product import script.
  1073.                                    For Product Magento id - '
  1074.                                     .$import_product->magento_id.' Product sku - '.$import_product->mp_sku);
  1075.                                 } else {
  1076.                                     if ($import_product->product_ebay_id) {
  1077.                                                $responses = $responseDoc->getElementsByTagName(
  1078.                                                    "ReviseFixedPriceItemResponse"
  1079.                                                );
  1080.                                     } else {
  1081.                                         $responses = $responseDoc->getElementsByTagName("AddFixedPriceItemResponse");
  1082.                                     }
  1083.                                                $itemID = "";
  1084.                                     foreach ($responses as $response) {
  1085.                                         $acks = $response->getElementsByTagName("Ack");
  1086.                                         $ack   = $acks->item(0)->nodeValue;
  1087.                                         //echo "Ack = $ack <BR />\n";   // Success if successful
  1088.                            
  1089.                                         $startTimes  = $response->getElementsByTagName("StartTime");
  1090.                                         $startTime   = $startTimes->item(0)->nodeValue;
  1091.                                         $start_date_array = date_parse($startTime);
  1092.                                         $start_date_string = date(
  1093.                                             'Y-m-d H:i:s',
  1094.                                             mktime(
  1095.                                                 $start_date_array['hour'],
  1096.                                                 $start_date_array['minute'],
  1097.                                                 $start_date_array['second'],
  1098.                                                 $start_date_array['month'],
  1099.                                                 $start_date_array['day'],
  1100.                                                 $start_date_array['year']
  1101.                                             )
  1102.                                         );
  1103.                            
  1104.                                         $endTimes  = $response->getElementsByTagName("EndTime");
  1105.                                         $endTime   = $endTimes->item(0)->nodeValue;
  1106.                                         $end_date_array = date_parse($endTime);
  1107.                                         $end_date_string = date(
  1108.                                             'Y-m-d H:i:s',
  1109.                                             mktime(
  1110.                                                 $end_date_array['hour'],
  1111.                                                 $end_date_array['minute'],
  1112.                                                 $end_date_array['second'],
  1113.                                                 $end_date_array['month'],
  1114.                                                 $end_date_array['day'],
  1115.                                                 $end_date_array['year']
  1116.                                             )
  1117.                                         );
  1118.                              
  1119.                                         $itemIDs  = $response->getElementsByTagName("ItemID");
  1120.                                         $itemID   = $itemIDs->item(0)->nodeValue;
  1121.                              
  1122.                                         $ebay_link = "https://www.ebay.de/itm/".$itemID."?ViewItem=&item=".$itemID;
  1123.                              
  1124.                                         $feeNodes = $responseDoc->getElementsByTagName('Fee');
  1125.                                         foreach ($feeNodes as $feeNode) {
  1126.                                             $feeNames = $feeNode->getElementsByTagName("Name");
  1127.                                             if ($feeNames->item(0)) {
  1128.                                                              $feeName[] = $feeNames->item(0)->nodeValue;
  1129.                                                                                           $fees = $feeNode->getElementsByTagName('Fee');//Fee amount in Fee
  1130.                                                 $fee[] = $fees->item(0)->nodeValue;
  1131.                                             } // if feeName
  1132.                                         } // foreach $feeNode
  1133.      
  1134.                                                    $fee_array=array_combine($feeName, $fee);
  1135.                                                    $fee_array_serialize=serialize($fee_array);
  1136.      
  1137.                                                    DB::table('tbl_ebay_products')->where(
  1138.                                                        'magento_id',
  1139.                                                        $import_product->magento_id
  1140.                                                    )->update(
  1141.                                                        ['product_ebay_id' => $itemID,
  1142.                                                        'product_ebay_status' => '8',
  1143.                                                        'error' => '',
  1144.                                                        'error_code'=>'',
  1145.                                                        'error_short_msg'=>'',
  1146.                                                        'error_long_msg'=>'',
  1147.                                                        'cron_error'=>null,
  1148.                                                        'ebay_status' => 'Product Uploaded',
  1149.                                                        'ebay_list_start_time'=>$start_date_string,
  1150.                                                        'ebay_list_end_time'=>$end_date_string,
  1151.                                                        'ebay_fees'=>$fee_array_serialize,
  1152.                                                        'ebay_list_url'=>$ebay_link,
  1153.                                                        'ebay_product_xml'=>$xml]
  1154.                                                    );
  1155.                                                    $designerDetails = \App\Designer::where(
  1156.                                                        'designer_id',
  1157.                                                        $import_product->designer_id
  1158.                                                    )->first();
  1159.                      
  1160.                                                    $success_msg = "Congratulation!! You successfully created.
  1161. $import_product->mp_product.
  1162. on ebay.\n";
  1163.                                                    $success_msg .= "Please check your Product on ebay at
  1164. $ebay_link";
  1165.            
  1166.                                                 \Mail::raw(
  1167.                                                     $success_msg,
  1168.                                                     function ($message) use ($designerDetails) {
  1169.                                                         $message->to($designerDetails->designer_email)->bcc(
  1170.                                                             ['[email protected]','[email protected]']
  1171.                                                         )
  1172.                                                         //->cc('[email protected]')
  1173.                                                         ->subject(
  1174.                                                             'Congratulation!! Product Successfully Added on Ebay.'
  1175.                                                         );
  1176.                                                     }
  1177.                                                 );
  1178.                                         \Log::channel('ebay')->info('Congratulation!! You successfully created'
  1179.                                          . $import_product->mp_product.'
  1180.                                          On Ebay. Please check your Product on ebay at '.$ebay_link);
  1181.                                         if ($cronExist) {
  1182.                                             $endDate = date('Y-m-d H:i:s');
  1183.                                             callChannel($startDate, $endDate, $cronExist->id, 'ebay');
  1184.                                         }
  1185.                                     }
  1186.                                 }
  1187.                             }
  1188.                         }
  1189.                     }
  1190.                 }
  1191.             } catch (\Exception $e) {
  1192.                 $designerDetials = \App\Designer::where('designer_id', $import_product->designer_id)->first();
  1193.                 $error = $e->getMessage();
  1194.                 $cron_error = "Error : $error
  1195.             Product ID : $import_product->magento_id
  1196.             Product SKU : $import_product->mp_sku
  1197.             Designer Name = $designerDetials->designer_name
  1198.             Designer Email = $designerDetials->designer_email";
  1199.            
  1200.                 \Mail::raw(
  1201.                     $cron_error,
  1202.                     function ($message) {
  1203.                         $message->to('[email protected]')
  1204.                             ->bcc('[email protected]')
  1205.                             ->subject('Ebay Import Products Cron Error');
  1206.                     }
  1207.                 );
  1208.                 \Log::channel('ebay')->error('Error :'.$e->getMessage().' For Product ID -'
  1209.                  . $import_product->magento_id.' Product SKU = '.$import_product->mp_sku);
  1210.                 app('db')->rollback();
  1211.             }
  1212.         }
  1213.         //$xml = $dom->saveXML();
  1214.         //echo $xml;
  1215.         //exit;
  1216.     }
  1217.     public function getBrowseNodeImagesEbay($ebay_setting, $siteID, $imageurl)
  1218.     {
  1219.         $ebay_browse_url = array();
  1220.         $devID = config('ebay.Dev_ID');
  1221.         $appID = config('ebay.App_ID');
  1222.         $certID = config('ebay.Cert_ID');
  1223.         $comp_version = config('ebay.COMPATIBILITY_LEVEL');
  1224.         $ebay_server_url = config('ebay.SERVER_URL');
  1225.  
  1226.         $requestXmlBody = '<?xml version="1.0" encoding="utf-8"?>';
  1227.         $requestXmlBody.= '<UploadSiteHostedPicturesRequest xmlns="urn:ebay:apis:eBLBaseComponents">';
  1228.         $requestXmlBody.= "<RequesterCredentials>
  1229.        <eBayAuthToken>". trim($ebay_setting->production_user_tocken)."</eBayAuthToken>
  1230.        </RequesterCredentials>";
  1231.         $requestXmlBody.= '<ErrorLanguage>en_US</ErrorLanguage>';
  1232.         $requestXmlBody.= "<Version>" .$comp_version. "</Version>";
  1233.         $requestXmlBody.= "<ExternalPictureURL>".trim($imageurl)."</ExternalPictureURL>";
  1234.         $requestXmlBody.= '</UploadSiteHostedPicturesRequest>';
  1235.       //echo "<pre>";print_r($requestXmlBody);exit;
  1236.       // xml creation code ends for upload image services
  1237.       //Create a new eBay session with all details pulled in from included keys.php
  1238.         $session = new \EBaySessionProduct(
  1239.             $ebay_setting->production_user_tocken,
  1240.             $devID,
  1241.             $appID,
  1242.             $certID,
  1243.             $ebay_server_url,
  1244.             $comp_version,
  1245.             $siteID,
  1246.             'UploadSiteHostedPictures'
  1247.         );
  1248.       //send the request and get response
  1249.         $responseXml = $session->sendHttpRequest($requestXmlBody);
  1250.         if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
  1251.             \Log::channel('ebay')
  1252.             ->info('Ebay not getting any response during browse measurement image upload for image - ' . $imageurl);
  1253.         } else {
  1254.             $responseDoc = new \DomDocument();
  1255.             $responseDoc->loadXML($responseXml);
  1256.             $errors = $responseDoc->getElementsByTagName('Errors');
  1257.             if ($errors->length == 0) {
  1258.                 $responses = $responseDoc->getElementsByTagName("UploadSiteHostedPicturesResponse");
  1259.                 foreach ($responses as $response) {
  1260.                     $acks = $response->getElementsByTagName("Ack");
  1261.                     $ack = $acks->item(0)->nodeValue;
  1262.                     //echo "Ack = $ack <BR />\n";   // Success if successful
  1263.                     $picturesDatas = $response->getElementsByTagName("SiteHostedPictureDetails");
  1264.                    
  1265.                     foreach ($picturesDatas as $picturesData) {
  1266.                             $fullurls = $picturesData->getElementsByTagName("FullURL");
  1267.                             //$fullurl[]   = $fullurls->item(0)->nodeValue;
  1268.                             $ebay_browse_url[] = $fullurls->item(0)->nodeValue;
  1269.                     }
  1270.                 }
  1271.             } else {
  1272.                 $error = $errors->item(0)->getElementsByTagName('SeverityCode');
  1273.                 $errorDB = $error->item(0)->nodeValue;
  1274.                 if ($errors->length > 0 && $errorDB != 'Warning') {
  1275.                     $code = $errors->item(0)->getElementsByTagName('ErrorCode');
  1276.                     $shortMsg = $errors->item(0)->getElementsByTagName('ShortMessage');
  1277.                     $longMsg = $errors->item(0)->getElementsByTagName('LongMessage');
  1278.                     $codeDB = $code->item(0)->nodeValue;
  1279.                     $shortMsgDB = (count($shortMsg) > 0) ?
  1280.                     str_replace(">", "&gt;", str_replace("<", "&lt;", $shortMsg->item(0)->nodeValue))
  1281.                     : '';
  1282.                     $longMsgDB = (count($longMsg) > 0) ?
  1283.                     str_replace(">", "&gt;", str_replace("<", "&lt;", $longMsg->item(0)->nodeValue))
  1284.                     : '';
  1285.                     \Log::channel('ebay')
  1286.                     ->info('Ebay getting some error during browse measurement image upload for image - ' . $imageurl .
  1287.                       'Error:' .$errorDB.'
  1288.                      Error Code:' .$codeDB.'
  1289.                      Error Short Msg:' .$shortMsgDB.'
  1290.                      Error Long Msg:' .$longMsgDB);
  1291.                 } else {
  1292.                     $responses = $responseDoc->getElementsByTagName("UploadSiteHostedPicturesResponse");
  1293.                     foreach ($responses as $response) {
  1294.                         $acks = $response->getElementsByTagName("Ack");
  1295.                         $ack = $acks->item(0)->nodeValue;
  1296.                         //echo "Ack = $ack <BR />\n";   // Success if successful
  1297.                         $picturesDatas = $response->getElementsByTagName("SiteHostedPictureDetails");
  1298.                        
  1299.                         foreach ($picturesDatas as $picturesData) {
  1300.                             $fullurls = $picturesData->getElementsByTagName("FullURL");
  1301.                             //$fullurl[]   = $fullurls->item(0)->nodeValue;
  1302.                             $ebay_browse_url[] = $fullurls->item(0)->nodeValue;
  1303.                         }
  1304.                     }
  1305.                 }
  1306.             }
  1307.         }
  1308.         return $ebay_browse_url;
  1309.     }
  1310.     public function getMeasurementImage($sku, $language)
  1311.     {
  1312.         $measureMentImage = \App\BrowseMeasurementImage::with('browseData')
  1313.         ->whereHas('browseData', function ($query) use ($sku, $language) {
  1314.             $query->where('sku', '=', $sku)->where('language', '=', $language);
  1315.         })->first();
  1316.         return $measureMentImage['measurement_image'];
  1317.     }
  1318.     public function getCategorySpecifics($category_id, $ebay_setting, $siteID, $category_verb)
  1319.     {
  1320.         $new_recommendation_array = array();
  1321.         $devID = config('ebay.Dev_ID');
  1322.         $appID = config('ebay.App_ID');
  1323.         $certID = config('ebay.Cert_ID');
  1324.         $comp_version = config('ebay.COMPATIBILITY_LEVEL');
  1325.         $ebay_server_url = config('ebay.SERVER_URL');
  1326.        
  1327.         $dom = new \DOMDocument();
  1328.  
  1329.         $dom->encoding = 'utf-8';
  1330.  
  1331.         $dom->xmlVersion = '1.0';
  1332.  
  1333.         $dom->formatOutput = true;
  1334.        
  1335.         $root = $dom->createElementNS('urn:ebay:apis:eBLBaseComponents', 'GetCategorySpecificsRequest');
  1336.  
  1337.         $request_node = $dom->createElement('RequesterCredentials');
  1338.  
  1339.         $ebay_auth = $dom->createElement('eBayAuthToken', $ebay_setting->production_user_tocken);
  1340.  
  1341.         $request_node->appendChild($ebay_auth);
  1342.  
  1343.         $root->appendChild($request_node);
  1344.        
  1345.         $detail_node = $dom->createElement('DetailLevel', 'ReturnAll');
  1346.        
  1347.         $root->appendChild($detail_node);
  1348.        
  1349.         $category_id_node = $dom->createElement('CategoryID', $category_id);
  1350.        
  1351.         $root->appendChild($category_id_node);
  1352.        
  1353.         $err_lang_node = $dom->createElement('ErrorLanguage', 'de_DE');
  1354.        
  1355.         $root->appendChild($err_lang_node);
  1356.        
  1357.         $war_level_node = $dom->createElement('WarningLevel', 'High');
  1358.        
  1359.         $root->appendChild($war_level_node);
  1360.        
  1361.         $ver_node = $dom->createElement('Version', $comp_version);
  1362.        
  1363.         $root->appendChild($ver_node);
  1364.        
  1365.         $dom->appendChild($root);
  1366.        
  1367.         $xml = $dom->saveXML();
  1368.        
  1369.         $ebay_category_specifics = new \EBaySessionProduct(
  1370.             $ebay_setting->production_user_tocken,
  1371.             $devID,
  1372.             $appID,
  1373.             $certID,
  1374.             $ebay_server_url,
  1375.             $comp_version,
  1376.             $siteID,
  1377.             $category_verb
  1378.         );
  1379.                    
  1380.         $responseXml = $ebay_category_specifics->sendHttpRequest($xml);
  1381.        
  1382.         $array = json_decode(json_encode((array)simplexml_load_string($responseXml)), true);
  1383.        
  1384.         $cat_namerecommendations = $array['Recommendations']['NameRecommendation'];
  1385.        
  1386.         foreach ($cat_namerecommendations as $recommendation_key => $recommendation_value) {
  1387.             if (isset($recommendation_value['ValidationRules']['MinValues'])) {
  1388.                 $new_recommendation_array[] = $recommendation_value;
  1389.             }
  1390.         }
  1391.         return $new_recommendation_array;
  1392.     }
  1393.     public function getCategoryFeatures($category_id, $ebay_setting, $siteID, $category_verb)
  1394.     {
  1395.         $new_recommendation_array = array();
  1396.         $devID = config('ebay.Dev_ID');
  1397.         $appID = config('ebay.App_ID');
  1398.         $certID = config('ebay.Cert_ID');
  1399.         $comp_version = config('ebay.COMPATIBILITY_LEVEL');
  1400.         $ebay_server_url = config('ebay.SERVER_URL');
  1401.        
  1402.         $dom = new \DOMDocument();
  1403.  
  1404.         $dom->encoding = 'utf-8';
  1405.  
  1406.         $dom->xmlVersion = '1.0';
  1407.  
  1408.         $dom->formatOutput = true;
  1409.        
  1410.         $root = $dom->createElementNS('urn:ebay:apis:eBLBaseComponents', 'GetCategoryFeaturesRequest');
  1411.  
  1412.         $request_node = $dom->createElement('RequesterCredentials');
  1413.  
  1414.         $ebay_auth = $dom->createElement('eBayAuthToken', $ebay_setting->production_user_tocken);
  1415.  
  1416.         $request_node->appendChild($ebay_auth);
  1417.  
  1418.         $root->appendChild($request_node);
  1419.        
  1420.         $detail_node = $dom->createElement('DetailLevel', 'ReturnAll');
  1421.        
  1422.         $root->appendChild($detail_node);
  1423.        
  1424.         $category_id_node = $dom->createElement('CategoryID', $category_id);
  1425.        
  1426.         $root->appendChild($category_id_node);
  1427.        
  1428.         $feature_id_node = $dom->createElement('FeatureID', 'EANEnabled');
  1429.        
  1430.         $root->appendChild($feature_id_node);
  1431.        
  1432.         $view_all_node = $dom->createElement('ViewAllNodes', true);
  1433.        
  1434.         $root->appendChild($view_all_node);
  1435.        
  1436.         $err_lang_node = $dom->createElement('ErrorLanguage', 'de_DE');
  1437.        
  1438.         $root->appendChild($err_lang_node);
  1439.        
  1440.         $war_level_node = $dom->createElement('WarningLevel', 'High');
  1441.        
  1442.         $root->appendChild($war_level_node);
  1443.        
  1444.         $ver_node = $dom->createElement('Version', $comp_version);
  1445.        
  1446.         $root->appendChild($ver_node);
  1447.        
  1448.         $dom->appendChild($root);
  1449.        
  1450.         $xml = $dom->saveXML();
  1451.        
  1452.         $ebay_category_features = new \EBaySessionProduct(
  1453.             $ebay_setting->production_user_tocken,
  1454.             $devID,
  1455.             $appID,
  1456.             $certID,
  1457.             $ebay_server_url,
  1458.             $comp_version,
  1459.             $siteID,
  1460.             $category_verb
  1461.         );
  1462.                    
  1463.         $responseXml = $ebay_category_features->sendHttpRequest($xml);
  1464.        
  1465.         $arrayeanenabled = json_decode(json_encode((array)simplexml_load_string($responseXml)), true);
  1466.        
  1467.         return $arrayeanenabled;
  1468.     }
  1469.     public function getRandomEAN($length)
  1470.     {
  1471.         $chars = "1234567890";
  1472.           $clen   = strlen($chars)-1;
  1473.           $id  = '';
  1474.  
  1475.         for ($i = 0; $i < $length; $i++) {
  1476.             $id .= $chars[mt_rand(0, $clen)];
  1477.         }
  1478.           return ($id);
  1479.     }
  1480.     public function generateEAN($number, $fake_country)
  1481.     {
  1482.         $code = $fake_country . str_pad($number, 9, '0', STR_PAD_LEFT);
  1483.         $weightflag = true;
  1484.         $sum = 0;
  1485.         // Weight for a digit in the checksum is 3, 1, 3.. starting from the last digit.
  1486.         // loop backwards to make the loop length-agnostic. The same basic functionality
  1487.         // will work for codes of different lengths.
  1488.         for ($i = strlen($code) - 1; $i >= 0; $i--) {
  1489.             $sum += (int)$code[$i] * ($weightflag?3:1);
  1490.             $weightflag = !$weightflag;
  1491.         }
  1492.         $code .= (10 - ($sum % 10)) % 10;
  1493.         return $code;
  1494.     }
  1495.     public function arrayMsort($array, $cols)
  1496.     {
  1497.         $colarr = array();
  1498.         foreach ($cols as $col => $order) {
  1499.             $colarr[$col] = array();
  1500.             foreach ($array as $k => $row) {
  1501.                 $colarr[$col]['_'.$k] = strtolower($row[$col]);
  1502.             }
  1503.         }
  1504.         $eval = 'array_multisort(';
  1505.         foreach ($cols as $col => $order) {
  1506.             $eval .= '$colarr[\''.$col.'\'],'.$order.',';
  1507.         }
  1508.         $eval = substr($eval, 0, -1).');';
  1509.         eval($eval);
  1510.         $ret = array();
  1511.         foreach ($colarr as $col => $arr) {
  1512.             foreach ($arr as $k => $v) {
  1513.                 $k = substr($k, 1);
  1514.                 if (!isset($ret[$k])) {
  1515.                     $ret[$k] = $array[$k];
  1516.                 }
  1517.                 $ret[$k][$col] = $array[$k][$col];
  1518.             }
  1519.         }
  1520.         return $ret;
  1521.     }
  1522. }
Add Comment
Please, Sign In to add comment