function formatProduct($product) { //Price // 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']) . $this->currency; // $sale_price = $this->getMapping('sale_price'); // if ($sale_price != null) // $sale_price->enabled = $product->attributes['has_sale_price']; // if ($product->attributes['has_sale_price']) // $product->attributes['sale_price'] = sprintf($this->currency_format, $product->attributes['sale_price']) . $this->currency; //Images now soft-coded foreach ($product->imgurls as $image_count => $imgurl) { $product->attributes['additional_image_link' . $image_count] = $imgurl; if ($image_count > 9) { break; } } //******************************************************************** //Make sure all the fields for this product are mapped //******************************************************************** $arrayKey = array(); $keyCount = 0; if ($this->mapAttributesOnTheFly) { foreach ($product->attributes as $key => $value) { //$keyto = str_replace(' ', '_', $key); //if ($this->getMappingByMapto($keyto) == null) if ($this->getMappingByMapto($key) == null) { if ($key != 'category_ids') { //temp solution for spaces in xml names. Need solution for all illegal chars: /, <, > $this->addAttributeMapping($key, str_replace(' ', '._', $key), $this->forceCData); } } } } return parent::formatProduct($product); }
function formatProduct($product) { global $pfcore; //******************************************************************** //Prepare the Product Attributes //******************************************************************** //******************************************************************** //Google date, ISO 8601 format. //Timezone Bug in WordPress: a manual offset, for example UTC+5:00 will show offset of 0 //Fix: Select specific region, example: Toronto //******************************************************************** 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\\TH:i:sO', $product->attributes['sale_price_dates_from']); $product->attributes['sale_price_dates_to'] = $pfcore->localizedDate('Y-m-d\\TH:i:sO', $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']; } } //******************************************************************** //Validation checks & Error messages //******************************************************************** if (!isset($product->attributes['brand']) || strlen($product->attributes['brand']) == 0) { if ($this->getMappingByMapto('g:identifier_exists') == null) { $this->addErrorMessage(2000, 'Missing brand for ' . $product->attributes['title']); } } return parent::formatProduct($product); }
function formatProduct($product) { //******************************************************************** //Prepare the Product Attributes //******************************************************************** //PLA //$product->attributes['link'] .= '?source=googleproduct&cvars='. rawurlencode($product->attributes['title']); //******************************************************************** //Validation checks & Error messages //******************************************************************** if (!isset($product->attributes['brand']) || strlen($product->attributes['brand']) == 0) { if ($this->getMappingByMapto('g:identifier_exists') == null && $this->getMappingByMapto('`in') == null && $this->getMappingByMapto('g:brand') == null) { $this->addErrorMessage(2000, 'Missing brand for ' . $product->attributes['title']); } } return parent::formatProduct($product); }