function formatProduct($product) { //For CSV files: replace all " with "" //make rule? $product->attributes['link'] = str_replace('https://', 'http://', $product->attributes['link']); $product->attributes['feature_imgurl'] = str_replace('https://', 'http://', $product->attributes['feature_imgurl']); return parent::formatProduct($product); }
function formatProduct($product) { //Prepare input: $product->attributes['feature_imgurl'] = str_replace('https://', 'http://', $product->attributes['feature_imgurl']); if ($product->attributes['stock_status'] == 1) { $product->attributes['stock_status'] = 'In Stock'; } else { $product->attributes['stock_status'] = 'Out Of Stock'; } //Allowed condition values: New, Open Box, OEM, Refurbished, Pre-Owned, Like New, Good, Very Good, Acceptable return parent::formatProduct($product); }
function formatProduct($product) { //Cheat: These three fields aren't ready to be attributes yet, so adding manually: //******************************************************************** //Make sure all the fields for this product are mapped //******************************************************************** if ($this->mapAttributesOnTheFly) { foreach ($product->attributes as $key => $value) { if ($this->getMappingByMapto($key) == null) { if ($key != 'category_ids') { $this->addAttributeMapping($key, $key, true); //enclose in quotes + escape any inner quotes $this->addRule('csv_standard', 'CSVStandard', array($key)); } } } } return parent::formatProduct($product); }
function formatProduct($product) { //cheat: Remap these if ($product->attributes['stock_status'] == 1) { $product->attributes['stock_status'] = 'in stock'; } else { $product->attributes['stock_status'] = '0'; } //Cycle through required attributes. If missing, show error //$error_count = 0; //<-- No need... $this->addErrorMessage() already counts the error messages of matching IDs foreach ($this->attributeMappings as $thisAttributeMapping) { if ($thisAttributeMapping->isRequired && ($thisAttributeMapping->mapTo == 'Delivery_time' || $thisAttributeMapping->mapTo == 'Delivery_cost')) { if (!isset($product->attributes[$thisAttributeMapping->attributeName]) || strlen($product->attributes[$thisAttributeMapping->attributeName]) == 0) { $this->addErrorMessage(12000, 'Missing required: ' . $thisAttributeMapping->mapTo); $this->productCount--; //break; } //$error_count++; } } return parent::formatProduct($product); }
function formatProduct($product) { $variantUPC = ''; $variantMfr = ''; if ($product->attributes['isVariation']) { //Not used in original code //$variantUPC = rand(); //$variantMfr = rand(); } //upc if (!isset($product->attributes['upc'])) { $product->attributes['n/a'] = 'n/a'; } //ProductURL: automatically pulled from "link". If you do not have a URL for the product, include your company website. //category $category = explode(":", $this->current_category); if (isset($category[0])) { $product->attributes['current_category'] = trim($category[0]); } else { $product->attributes['current_category'] = 'no_category_selected'; } //style: 14 different styles if (!isset($product->attributes['Style'])) { $product->attributes['Style'] = 'see Houzz template for acceptable entries'; } //additional images $image_count = 1; foreach ($product->imgurls as $imgurl) { $image_index = "Image{$image_count}"; $product->attributes[$image_index] = str_replace('https://', 'http://', $imgurl); $image_count++; if ($image_count >= 5) { break; } } //result code (error) notifications foreach ($this->attributeMappings as $thisAttributeMapping) { if ($thisAttributeMapping->isRequired && ($thisAttributeMapping->mapTo == 'LeadTimeMax' || $thisAttributeMapping->mapTo == 'LeadTimeMin')) { if (!isset($product->attributes[$thisAttributeMapping->attributeName]) || strlen($product->attributes[$thisAttributeMapping->attributeName]) == 0) { $this->addErrorMessage(19000, 'Missing required: ' . $thisAttributeMapping->mapTo); $this->productCount--; } } if ($thisAttributeMapping->isRequired && $thisAttributeMapping->mapTo == 'Style') { if (!isset($product->attributes[$thisAttributeMapping->attributeName]) || strlen($product->attributes[$thisAttributeMapping->attributeName]) == 0) { $this->addErrorMessage(19001, 'Missing required: ' . $thisAttributeMapping->mapTo); $this->productCount--; } } } return parent::formatProduct($product); //$this->productCount--; }
function formatProduct($product) { //cheat: Remap these if ($product->attributes['condition'] == 'New') { $product->attributes['condition'] = '1'; } //$product->attributes['OfferExpeditedShipping'] = 1; //result code notificaitons $error_count = 0; foreach ($this->attributeMappings as $thisAttributeMapping) { if ($thisAttributeMapping->isRequired && ($thisAttributeMapping->mapTo == 'ProductId' || $thisAttributeMapping->mapTo == 'ProductIdType' || $thisAttributeMapping->mapTo == 'OfferExpeditedShipping')) { if (!isset($product->attributes[$thisAttributeMapping->attributeName]) || strlen($product->attributes[$thisAttributeMapping->attributeName]) == 0) { $this->addErrorMessage(1400 . $error_count, 'Missing required: ' . $thisAttributeMapping->mapTo); $error_count++; } } } if ($error_count > 0) { $this->productCount--; } return parent::formatProduct($product); }
function formatProduct($product) { //if product weight is in ounces, convert to lbs if ($this->weight_unit == 'oz' || $this->weight_unit == 'ounces') { $product_weight_in_lbs = $product->attributes['weight'] * 0.0625; $product->attributes['weight'] = sprintf('%0.2f', $product_weight_in_lbs); } //additional-images if ($this->allow_additional_images && count($product->imgurls) > 0) { $product->attributes['additional-images'] = implode('|', $product->imgurls); } //category-id $product->attributes['current_category'] = explode("\t", $product->attributes['current_category'])[0]; //seller id $product->attributes['seller_id'] = $this->seller_id; //result code notificaitons if (!isset($this->seller_id) || strlen($product->attributes['seller_id']) == 0) { $this->addErrorMessage(1000, 'seller-id not configured. Add advanced command: $seller-id = ....', true); $this->productCount--; //Make sure the parent class knows we failed to make a product $this->merchant_id = ''; return ''; } // if (!isset($this->seller_id) && !isset($product->attributes['seller-id'])) { // $this->addErrorMessage(1000, 'Seller ID not configured. Need advanced command: $seller-id = ....'); // $this->addErrorMessage(1001, '*Note: Seller ID is the number in the upper right hand corner of your Rakuten Merchant Tools Page.'); // $this->productCount--; //Make sure the parent class knows we failed to make a product // return ''; // } //Prepare input (New Rakuten SKU Feed) // if (isset($this->seller_id)) // $product->attributes['seller-id'] = $this->seller_id; // $product->attributes['gtin'] = $product->attributes['sku']; // while (strlen($product->attributes['gtin']) < 12) // $product->attributes['gtin'] = '0' . $product->attributes['gtin']; // $product->attributes['listing_price'] = sprintf($this->currency_format, $product->attributes['regular_price']); return parent::formatProduct($product); }
function formatProduct($product) { if ($product->attributes['isVariation']) { //Not used in original code //$variantUPC = rand(); //$variantMfr = rand(); } //Prepare //$product->attributes['Action'] = "VerifyAdd"; $category = explode(":", $this->current_category); if (isset($category[1])) { $product->attributes['category'] = trim($category[1]); } else { $product->attributes['category'] = 'no_category_selected'; } $product->attributes['feature_imgurl'] = str_replace('https://', 'http://', $product->attributes['feature_imgurl']); if (!isset($product->attributes['quantity'])) { $product->attributes['quantity'] = $product->attributes['stock_quantity']; } if (!isset($product->attributes['ConditionID'])) { $product->attributes['ConditionID'] = '1000'; //1000=new, 3000=used } if (!isset($product->attributes['Duration'])) { $product->attributes['Duration'] = 'GTC'; //5,7,10,GTC } if (!isset($product->attributes['Format'])) { $product->attributes['Format'] = "FixedPrice"; } if (!isset($product->attributes['ReturnsAcceptedOption'])) { $product->attributes['ReturnsAcceptedOption'] = 'ReturnsAccepted'; } $shippingWeight = $product->attributes['weight']; $shippingTypeCalculated = strtolower($product->attributes['ShippingType']); if (isset($shippingWeight) && $shippingTypeCalculated == 'calculated') { if ($this->weight_unit == 'kg' || $this->weight_unit == 'lbs') { $shippingWeight = number_format($shippingWeight, 2, '.', ''); $shippingWeight_int = explode('.', $shippingWeight, 2); } //WeightMajor: whole number portion of the shipping weight. 3 = 3lbs //WeightMinor: Imperial: ounces; Metric: reflect hundreths of kg switch ($this->weight_unit) { case 'lbs': $product->attributes['WeightMajor'] = $shippingWeight_int[0]; $product->attributes['WeightMinor'] = round(($shippingWeight - $shippingWeight_int[0]) * 16, 0); //1 lb = 16 oz $product->attributes['weight_unit'] = 'lbs'; break; case 'kg': $product->attributes['WeightMajor'] = $shippingWeight_int[0]; $product->attributes['WeightMinor'] = round(($shippingWeight - $shippingWeight_int[0]) * 100, 0); $product->attributes['weight_unit'] = 'kg'; break; case 'g': $product->attributes['WeightMajor'] = ''; $product->attributes['WeightMinor'] = round($shippingWeight * 0.1, 0); $product->attributes['weight_unit'] = 'g'; break; case 'oz': $product->attributes['WeightMajor'] = ''; $product->attributes['WeightMinor'] = round($shippingWeight, 0); $product->attributes['weight_unit'] = 'oz'; break; default: $product->attributes['WeightMajor'] = ''; $product->attributes['WeightMinor'] = ''; //$shippingWeight_int[1]; $product->attributes['weight_unit'] = $this->weight_unit; } } else { $product->attributes['weight_unit'] = ''; } //weight unit not required for flat-rate shipping return parent::formatProduct($product); }
function formatProduct($product) { global $pfcore; $variantUPC = ''; $variantMfr = ''; if ($product->attributes['isVariation']) { //Not used in original code //$variantUPC = rand(); //$variantMfr = rand(); } /* This is an essential requirement from Grazia and gives the store owner the ability to simply select 'Yes' or 'No' at the product level. GraziaShop Business rule: setAttributeDefualt business-attribute as none PGraziaBusinessRule where business-attribute is the custom field containing 'yes' or 'no' */ //additional image links if ($this->allow_additional_images && count($product->imgurls) > 0) { $product->attributes['additional_image_links'] = implode(',', $product->imgurls); } //sale price from/to dates //if (($product->attributes['has_sale_price']) { if (isset($product->attributes['sale_price_dates_from']) && isset($product->attributes['sale_price_dates_to'])) { $product->attributes['sale_price_dates_from'] = $pfcore->localizedDate('Y-m-d H:i:s', $product->attributes['sale_price_dates_from']); $product->attributes['sale_price_dates_to'] = $pfcore->localizedDate('Y-m-d H:i:s', $product->attributes['sale_price_dates_to']); if (strlen($product->attributes['sale_price_dates_from']) > 0 && strlen($product->attributes['sale_price_dates_to']) > 0) { $product->attributes['sale_price_effective_date'] = $product->attributes['sale_price_dates_from'] . ' ' . $product->attributes['sale_price_dates_to']; } } //currency // if (!isset($product->attributes['currency']) || (strlen($product->attributes['currency']) == 0)) //$product->attributes['currency'] = $this->currency; //stock // if ( !isset($product->attributes['quantity']) ) // $product->attributes['quantity'] = $product->attributes['stock_quantity']; //langauge: EN, FR, IT $language = get_locale(); if (strpos($language, '_') !== false) { $language = substr($language, 0, strpos($language, '_')); $product->attributes['language'] = strtoupper($language); } return parent::formatProduct($product); }
function formatProduct($product) { //cheat: Remap these //Max 6 Additional Images $product->attributes['item_images'] = $product->attributes['feature_imgurl']; if ($this->allow_additional_images && count($product->imgurls) > 0) { $image_count = 1; foreach ($product->imgurls as $imgurl) { $product->attributes['additional_images'] .= ',' . $imgurl; $image_count++; if ($image_count >= 7) { break; } } $product->attributes['item_images'] .= $product->attributes['additional_images']; } //if (strlen($product->attributes['additional_images']) > 0) // $product->attributes['additional_images'] = substr($product->attributes['additional_images'], 0, -1); $product->attributes['currency'] = $this->currency; if ($this->newegg_combo_title) { $title_dash = " - "; $title_combo = ""; //Modify Website Short Title to include Brand - Title - Flavour (if exists) - Size (if exists) $title_combo = $product->attributes['brand'] . $title_dash . $product->attributes['title']; if (!empty($product->attributes['flavour'])) { $title_combo = $title_combo . $title_dash . $product->attributes['flavour']; } if (!empty($product->attributes['size'])) { $title_combo = $title_combo . $title_dash . $product->attributes['size']; } $product->attributes['title'] = $title_combo; } $product->attributes['shipping'] = $this->newegg_shipping; if (!isset($this->newegg_shipping) || strlen((string) $product->attributes['shipping']) == 0) { $this->addErrorMessage(17000, 'Shipping not configured. Need advanced command: $newegg_shipping = ....', true); //$this->addErrorMessage(9001, 'You can find your Merchant ID in the top left corner of the ShareASale web interface for advertisers/merchants (login required)', true); $this->productCount--; $this->merchant_id = ''; } return parent::formatProduct($product); }
function formatProduct($product) { //Prepare input $product->attributes['feature_imgurl'] = str_replace('https://', 'http://', $product->attributes['feature_imgurl']); $image_count = 1; $product->attributes['additional_images' . $image_count] = ''; foreach ($product->imgurls as $imgurl) { $product->attributes['additional_images' . $image_count] .= $imgurl; $product->attributes['additional_images' . $image_count] = str_replace('https://', 'http://', $product->attributes['additional_images' . $image_count]); $image_count++; if ($image_count >= 10) { break; } } if ($product->attributes['stock_status'] == 1) { $product->attributes['stock_status'] = 'Yes'; } else { $product->attributes['stock_status'] = 'No'; } if (!isset($product->attributes['brand']) || strlen($product->attributes['brand']) == 0) { $this->addErrorMessage(15000, 'Missing brand for ' . $product->attributes['title']); } return parent::formatProduct($product); }
function formatProduct($product) { $variantUPC = ''; $variantMfr = ''; if ($product->attributes['isVariation']) { //Not used in original code //$variantUPC = rand(); //$variantMfr = rand(); } //Prepare //$product->attributes['id'] = $product->attributes['id'] . $variantUPC; //Not used in original code //$product->attributes['mfr_part_number'] = $product->attributes['id'] . $variantMfr; $image_count = 1; foreach ($product->imgurls as $imgurl) { $image_index = "other_image_url{$image_count}"; $product->attributes[$image_index] = $imgurl; $image_count++; if ($image_count >= 9) { break; } } //List the product price in US dollars, without a $ sign, commas, text, or quotation marks. $product->attributes['price'] = $product->attributes['regular_price']; if ($product->attributes['has_sale_price'] && $product->attributes['sale_price'] != "") { $product->attributes['price'] = $product->attributes['sale_price']; } //$product->attributes['shipping_cost'] = '0.00 '; if (isset($product->attributes['weight'])) { $product->attributes['shipping_weight'] = $product->attributes['weight']; } //else { // $product->attributes['shipping_weight'] = '0 kg'; // $product->attributes['weight'] = '0 kg'; // } return parent::formatProduct($product); }
function formatProduct($product) { //Category: ShopZilla accepts breadcrumbs (text) $category = explode(";", $this->current_category); if (isset($category[0])) { $product->attributes['curent_category'] = trim($category[0]); } else { $product->attributes['curent_category'] = "0,000,001"; } //Other miscellaneous category id $product->attributes['curent_category'] = str_replace(',', '', $product->attributes['curent_category']); if (strpos($product->attributes['feature_imgurl'], 'https') !== false) { $product->attributes['feature_imgurl'] = str_replace('https://', 'http://', $product->attributes['feature_imgurl']); //Warn user because server might not be listening for http connections //$this->addErrorMessage(<Shopzilla Range Warning + 1>, 'Converted an https image url http ' . $product->attributes['title'] . image url); } //Images: Max 9 Additional Images if ($this->allow_additional_images && count($product->imgurls) > 0) { $product->attributes['additional_images'] = implode(',', $product->imgurls); $product->attributes['additional_images'] = str_replace('https://', 'http://', $product->attributes['additional_images']); //$this->addErrorMessage(<Shopzilla Range Warning + 2>, 'Converted an https additional image to http ' . $product->attributes['title'] . image url); } //Availability if ($product->attributes['stock_status'] == 1) { $product->attributes['stock_status'] = 'In Stock'; } else { $product->attributes['stock_status'] = 'Out of Stock'; } //result code notificaitons //if (!isset($product->attributes['brand']) || (strlen($product->attributes['brand']) == 0)) // $this->addErrorMessage(13000, 'Missing brand for ' . $product->attributes['title']); return parent::formatProduct($product); }
function formatProduct($product) { //******************************************************************** //Prepare the Product Attributes //******************************************************************** //if ($product->attributes['isVariation']) //'Item Group ID' => $product->item_group_id; if (strlen($product->attributes['regular_price']) == 0) { $product->attributes['regular_price'] = '0.00'; } $product->attributes['regular_price'] = sprintf($this->currency_format, $product->attributes['regular_price']); if ($product->attributes['has_sale_price']) { $product->attributes['sale_price'] = sprintf($this->currency_format, $product->attributes['sale_price']); } //Note: Only In stock && New products will publish on Bing if ($product->attributes['stock_status'] == 1) { $product->attributes['availability'] = 'In Stock'; } else { $product->attributes['availability'] = 'Out of Stock'; } //if ($this->bingForceGoogleCategory) { //For this to work, we need to enable a Google taxonomy dialog box. //} //Need one day: Bingads_grouping, Bingads_label, Bingads_redirect //******************************************************************** //Validation checks & Error messages //******************************************************************** /* title, brand, (MPN), Sku, b_category = 255 URL, ImageURL = 2000, UPC12 ISBN13 Description 5000 if (strlen($product->attributes['title']) > 255) { $product->attributes['title'] = substr($product->attributes['title'], 0, 254); $this->addErrorMessage(000, 'Title truncated for ' . $product->attributes['title'], true); }*/ return parent::formatProduct($product); }
function formatProduct($product) { //******************************************************************** //Prepare //******************************************************************** $product->attributes['merchant_id'] = $this->merchant_id; $product->attributes['description_short'] = $product->description_short; if ($product->attributes['stock_status'] == 1) { $product->attributes['stock_status'] = 'instock'; } else { $product->attributes['stock_status'] = 'soldout'; } $cat = explode(':', $this->current_category); if (count($cat) < 2) { $product->attributes['current_category'] = ''; } else { $product->attributes['current_category'] = (int) $cat[0]; } //******************************************************************** //Post-flight //******************************************************************** if (!isset($this->merchant_id) || strlen($product->attributes['merchant_id']) == 0) { $this->addErrorMessage(9000, 'MerchantID not configured. Need advanced command: $merchant-id = ....', true); //$this->addErrorMessage(9001, 'You can find your Merchant ID in the top left corner of the ShareASale web interface for advertisers/merchants (login required)', true); $this->productCount--; $this->merchant_id = ''; } return parent::formatProduct($product); }