diff --git a/magmi/plugins/extra/itemprocessors/attributedeleter/attributedeleterprocessor.php b/magmi/plugins/extra/itemprocessors/attributedeleter/attributedeleterprocessor.php new file mode 100644 index 00000000..f7847184 --- /dev/null +++ b/magmi/plugins/extra/itemprocessors/attributedeleter/attributedeleterprocessor.php @@ -0,0 +1,100 @@ + + * + * This allows select and multiselect attributes to be deleted in create mode. + */ +class AttributeDeleter extends Magmi_ItemProcessor +{ + public static $_VERSION = '1.0'; + + public function initialize($params) + { + // declare current class as attribute handler + $this->registerAttributeHandler($this, array("frontend_input:(select|multiselect)")); + } + + public function getPluginUrl() + { + return $this->pluginDocUrl('Attribute_Deleter'); + } + + public function getPluginVersion() + { + return self::$_VERSION; + } + + public function getPluginName() + { + return 'Attribute Deleter'; + } + + public function getPluginAuthor() + { + return 'Björn Tantau'; + } + + public function getShortDescription() + { + return 'This plugin deletes select/multiselect attributes with a value of "__MAGMI_DELETE__".'; + } + + /** + * attribute handler for Int typed attributes + * + * @param int $pid + * : product id + * @param array $item + * : item to inges + * @param int $storeid + * : store for attribute value storage + * @param int $attrcode + * : attribute code + * @param array $attrdesc + * : attribute metadata + * @param mixed $ivalue + * : input value to import + * @return new int value to set + * + * Many attributes are int typed, so we need to handle all cases like : + * - select + * - tax id + * - boolean + * - status + * - visibility + */ + public function handleIntAttribute($pid, &$item, $storeid, $attrcode, $attrdesc, $ivalue) + { + if ($attrdesc["frontend_input"] == "select" && $ivalue == '__MAGMI_DELETE__') + { + return $ivalue; + } + return null; + } +} \ No newline at end of file