1. velom
  2. RO CSVI
  3. Thursday, 25 January 2018
  4.  Subscribe via email
Hello, first let me say - ACE component so far.

My version number is 7.4.1
Joomla version 3.8.3
VM is 3.2.8

But I see one major flaw that is connected to EXPORTING all the products in XML format with all the custom fields per product (they are custom fields for all)

Since I've used CSVI a year ago I set up the export really easily and tested it. It works like a charm for every field except the custom fields which show the NAME for the custom field butr not the value - the value appears as - customsforall. When I try the custom_param - I can see the values.

So first teh backstory - we are doing an XML feed to another ecommerce platform that requires a specific XML structure - which is fine CSVI Pro supports it just fine.

This is the structure they require:

<product>
<id>[id]</id>
<product_code>[sku]</product_code>
<title>[name]</title>
<description>[description]</description>
<category>[category]</category>

<category_property name="[custom_title]">
<values>
<value>
<name>[custom_param]</name>
</value>
</values>
</category_property>

<manufacturer>[manufacturer]</manufacturer>
<price>[price]</price>
<quantity>[stock]</quantity>
<images>
<image>[images]</image>
</images>
<meta_title>[meta_title]</meta_title>
<meta_description>[meta_description]</meta_description>
</product>

As you can see I have already done everytthing accoring to your guide.

But when I export I see this (check the file)

As you can see suddenly the param and the custom title are not nested and in a different order. Also is the re a way for me to have a seperate title and value for each field rather than having them in one line like this.
Accepted Answer Pending Moderation
Hello,
But I see one major flaw that is connected to EXPORTING all the products in XML format with all the custom fields per product (they are custom fields for all)

Since I've used CSVI a year ago I set up the export really easily and tested it. It works like a charm for every field except the custom fields which show the NAME for the custom field butr not the value - the value appears as - customsforall. When I try the custom_param - I can see the values.

Yes you're right but that is not a flaw as that is how custom fields for all stores its values in database table.

As you can see suddenly the param and the custom title are not nested and in a different order. Also is the re a way for me to have a seperate title and value for each field rather than having them in one line like this.

There is no option in CSVI as of now to separate title and value but you can do that by creating a override for export and with custom coding in the override file.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 1
Accepted Answer Pending Moderation
Amazing - that is just what I needed.

Again ACE job guys will leave a great review.
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
Can you help me out a bit more - I am trying to create a override for export but cannot find where you insert the ~ sign between different custom fields so that I can replace it.
  1. more than a month ago
  2. RO CSVI
  3. # 3
Accepted Answer Pending Moderation
I think I found an implode statement - I will test and post you my modification if you can use it in the future for people that need something similar.
  1. more than a month ago
  2. RO CSVI
  3. # 4
Accepted Answer Pending Moderation
My override for the separation of the custom fields by names and values is:

case 'custom_value':
case 'custom_price':
case 'custom_param':
case 'custom_ordering':

$titlesArray = [];
$valuesArray = [];

if ($titlesArray==[]) {
// Get the custom title
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName('custom_title'));
$query->from($this->db->quoteName('#__virtuemart_customs', 'c'));
$query->leftJoin($this->db->quoteName('#__virtuemart_product_customfields', 'f') . ' ON c.virtuemart_custom_id = f.virtuemart_custom_id');
$query->where($this->db->quoteName('virtuemart_product_id') . ' = ' . (int) $record->virtuemart_product_id);
$query->where($this->db->quoteName('field_type') . ' NOT IN (' . $this->db->quote('R') . ', ' . $this->db->quote('Z') . ', ' . $this->db->quote('G') . ')');

// Check if we need to filter
$title_filter = $this->template->get('custom_title', array(), 'array');

if (!empty($title_filter) && $title_filter[0] !== '')
{
$query->where($this->db->quoteName('f.virtuemart_custom_id') . ' IN (' . implode(',', $title_filter) . ')');
}

$query->order(
array(
$this->db->quoteName('f.ordering'),
$this->db->quoteName('f.virtuemart_custom_id')
)
);
$this->db->setQuery($query);
$titles = $this->db->loadColumn();

if (is_array($titles))
{
$titlesArray = $titles;
}
else
{
//$fieldValue = '';
}
}
// Do some field sanity check if needed
if ($fieldname !== 'custom_ordering')
{
$fieldname = str_ireplace(array('custom_', '_param'), array('customfield_', '_params'), $fieldname);
}

if (!isset($this->customFields[$record->virtuemart_product_id][$fieldname]))
{
if ($fieldname === 'custom_ordering')
{
$qfield = $this->db->quoteName('cf.ordering', 'custom_ordering');
}
else
{
$qfield = $this->db->quoteName($fieldname);
}

$query = $this->db->getQuery(true)
->select($qfield)
->select(
$this->db->quoteName(
array(
'cf.virtuemart_customfield_id',
'cf.virtuemart_custom_id',
'cf.customfield_params',
'c.field_type',
'c.custom_element',
)
)
)
->from($this->db->quoteName('#__virtuemart_product_customfields', 'cf'))
->leftJoin(
$this->db->quoteName('#__virtuemart_customs', 'c')
. ' ON ' . $this->db->quoteName('c.virtuemart_custom_id') . ' = ' . $this->db->quoteName('cf.virtuemart_custom_id')
)
->where($this->db->quoteName('cf.virtuemart_product_id') . ' = ' . (int) $record->virtuemart_product_id);

// Check if we need to filter
$title_filter = $this->template->get('custom_title', array());

if (!empty($title_filter) && $title_filter[0] != '')
{
$query->where($this->db->quoteName('cf.virtuemart_custom_id') . ' IN (' . implode(',', $title_filter) . ')');
}

$query->order(
array(
$this->db->quoteName('cf.ordering'),
$this->db->quoteName('cf.virtuemart_custom_id')
)
);
$this->db->setQuery($query);
$customfields = $this->db->loadObjectList();
$this->log->add('Custom field query');

if (!empty($customfields))
{
$values = array();

foreach ($customfields as $customfield)
{
// Check for groups, we don't need them as they get handled automatically
if ($customfield->field_type !== 'G')
{
if ($fieldname === 'customfield_params' && $customfield->field_type !== 'C')
{
// Fire the plugin to empty any values needed
$result = $dispatcher->trigger(
'exportCustomValues',
array(
'plugin' => $customfield->custom_element,
'custom_param' => $customfield->customfield_params,
'virtuemart_product_id' => $record->virtuemart_product_id,
'virtuemart_custom_id' => $customfield->virtuemart_custom_id,
'virtuemart_customfield_id' => $customfield->virtuemart_customfield_id,
'log' => $this->log
)
);

if (is_array($result) && !empty($result))
{
$values = array_merge($values, $result[0]);
}
else
{
// Create the CSVI format
// option1[value1#value2;option2[value1#value2
$values[] = $customfield->customfield_params;
}
}
else
{
if ($customfield->$fieldname !== false && !is_null($customfield->$fieldname))
{
$fieldValue = $customfield->$fieldname;

// Apply currency formatting
if ($fieldname === 'customfield_price')
{
$fieldValue = $this->formatNumber($customfield->$fieldname);
}

$values[] = $fieldValue;
}
else
{
$values[] = '';
}
}
}
}

$this->customFields[$record->virtuemart_product_id][$fieldname] = $values;
$valuesArray = $this->customFields[$record->virtuemart_product_id][$fieldname];

$max = count($titlesArray) - 1;
$counter = 0;

while ($counter <= $max ){
$fieldValue .= "<category_property>".PHP_EOL;
$fieldValue .= "<category_property_names>".$titlesArray[$counter]."<category_property_names>".PHP_EOL;
$fieldValue .= "<values><names>".$valuesArray[$counter]."</names></values>".PHP_EOL;
$fieldValue .= "</category_property>".PHP_EOL;
$fieldValue .= PHP_EOL;
$counter++;
}

//$fieldValue = "<values><names>".implode('</names><names>', $result)."</names></values>";

//$fieldValue = "<values><names>".implode('</names><names>', $this->customFields[$record->virtuemart_product_id][$fieldname])."</names></values>";
}
else
{
$fieldValue = '';
}
}
else
{
$fieldValue = implode('~', $this->customFields[$record->virtuemart_product_id][$fieldname]);
}

$titlesArray = [];
$valuesArray = [];
break;


To use it you need to switch teh XML tags to your liking and use the custom_param field instead of the title
  1. more than a month ago
  2. RO CSVI
  3. # 5
Accepted Answer Pending Moderation
Hello,
Thank you for posting your solution.
Kind regards,

Tharuna

=========================
If you use our extensions, please post a rating and a review at the Joomla! Extension Directory
  1. more than a month ago
  2. RO CSVI
  3. # 6
  • Page :
  • 1


There are no replies made for this post yet.
Be one of the first to reply to this post!