1. davidmdavis
  2. RO CSVI
  3. Wednesday, 21 March 2018
  4.  Subscribe via email
Does anyone have any knowledge of this or any helpful ideas before I start? What I am looking to do is skip import of a K2 Item based on unique values in a particular extra field.
Accepted Answer Pending Moderation
Hello David,
You can create a Skip rule in CSVI and set the unique values of your K2 extra field in Values to match field in the rule. Now when CSVI gets a record matching to the values set in the rule the import of that record will be skipped.
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
The problem is the values of the K2 field for each record are a unique VIN number tied to that particular record so every time I update i would need to export all of those ids from k2 with csvi making it really a 3 step process. I was hoping to be able to do the work and make that automated by the import process. Read the extra field values for that particular field and build an array and check to see if that value is in array on import and skip if it is. I want to be able to do this for hundreds of records everyday as our available major unit inventory changes daily.

Thanks though for the reply. I am currently doing the export and add to rule and skip. I just want it as a single step as i have to do it so often.
  1. more than a month ago
  2. RO CSVI
  3. # 2
Accepted Answer Pending Moderation
Hello David,

The first thing comes to mind is to create your own rule. In this you can build the logic you need for identifying that record. This would primarily be a copy of the skip plugin we provide added with the additional logic you need for reading the VIN number. What I am understanding from your text is that the records with a specific VIN number that already exist in the database should not be imported again, correct?

Adding a skip record for every VIN number is a bit over the top as well. The only reasonable option I see is that custom rule plugin as you can add all your business logic into that.
Kind regards,

RolandD

=========================
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. # 3
Accepted Answer Pending Moderation
If you think that would be the way to go. I would attempt that first.
  1. more than a month ago
  2. RO CSVI
  3. # 4
Accepted Answer Pending Moderation
Hey David,

I do think that is the better way to go because you can add a database query to your plugin that simply checks if it already exists or not. There isn't even a need to build a list as that list is already in the database. The most tricky part is probably to figure out how that VIN number is stored by K2.
Kind regards,

RolandD

=========================
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. # 5
Accepted Answer Pending Moderation
This seems to work for a skip rule built from k2 custom field data. Would probably need to be modified to anyone elses needs.

defined('_JEXEC') or die;

/**
* HIN values.
*
* @package CSVI
* @subpackage Plugin.HIN
* @since 7.0
*/
class PlgCsvirulesHin extends RantaiPluginDispatcher
{
/**
* The unique ID of the plugin
*
* @var string
* @since 7.0
*/
private $id = 'csvihin';

/**
* Return the name of the plugin.
*
* @return array The name and ID of the plugin.
*
* @since 7.0
*/
public function getName()
{
return array('value' => $this->id, 'text' => 'CSVI HIN');
}

/**
* Method to get the name only of the plugin.
*
* @param string $plugin The ID of the plugin
*
* @return string The name of the plugin.
*
* @since 7.0
*/
public function getSingleName($plugin)
{
if ($plugin === $this->id)
{
return 'CSVI HIN';
}

return '';
}

/**
* Method to get the field options.
*
* @param string $plugin The ID of the plugin
* @param array $options An array of settings
*
* @return string The rendered form with plugin options.
*
* @since 7.0
* @throws RuntimeException
* @throws InvalidArgumentException
*/

/**
* Run the rule.
*
* @param string $plugin The ID of the plugin
* @param object $settings The plugin settings set for the field
* @param object $field The field being process
* @param CsviHelperFields $fields All fields used for import/export
*
* @return void.
*
* @since 7.0
*/
public function runRule($plugin, $settings, $field, $fields)
{
if ($plugin === $this->id)
{
//This is the Query to get the K2 Items needs some work
$db = JFactory::getDBO();
$select = "SELECT extra_fields FROM #__k2_items";
$db->setQuery($select);
$records = $db->loadObjectList();
//$records = $this->db->getIterator();
$matchValues = array();



foreach ($records as $record)
{
$matchValues[] =json_decode($record->extra_fields)[1]->value;

}

// Check if we have a multiple values
//var_dump($matchValues);

// Set the old value
$value = $field->value;


// If the field is empty and applywhenempty setting is no then do nothing
if ('' !== $value )
{

foreach ($matchValues as $matchVal)
{
if (strpos($value, $matchVal) !== false)
{

$fields->setProcessRecord(false);

}
}

}
}
}
}
  1. more than a month ago
  2. RO CSVI
  3. # 6
Accepted Answer Pending Moderation
Hello David,
Thank you for posting your solution. Hope it helps other users.
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. # 7
  • Page :
  • 1


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