plugins/extra/itemprocessors/currencyprice/CurrencyPriceProcessor.php
/**
     * you can add/remove columns for the item passed since it is passed by reference
     *
     * @param unknown_type $item
     *            : modifiable reference to item before import
     *            the $item is a key/value array with column names as keys and values as read from csv file.
     * @return bool :
     *         true if you want the item to be imported after your custom processing
     *         false if you want to skip item import after your processing
     */
you can add/remove columns for the item passed since it is passed by reference
@param unknown_type $item
: modifiable reference to item before import
the $item is a key/value array with column names as keys and values as read from csv file.
@return bool :
true if you want the item to be imported after your custom processing
false if you want to skip item import after your processing
you can add / remove columns for the item passed since it is passed by reference @param unknown_type $item : modifiable reference to item before import the $item is a key / value array with column names as keys and values as read from csv file . @return bool : true if you want the item to be imported after your custom processing false if you want to skip item import after your processing
public function processItemAfterId(&$item, $params = null)
    {
        $sku     = $params["product_id"];
        $table   = $this->tablename("catalog_product_compound_price");
        $prices  = $this->getPrices($item);
        $code_map      = $this->_websites;
        $website_codes = [ "admin" ];
        if (isset($item["websites"]) && !empty($item["websites"])) {
            $website_codes = preg_split('/,\s*/', $item["websites"]);
        }
        $website_ids  = array_filter(array_map(function ($code) use ($code_map) {
            if (isset($code_map[$code]) && !is_numeric($code)) {
                return $code_map[$code];
            } else if (is_numeric($code) && in_array($code, array_values($code_map))) {
                return $code;
            }
            return null;
        }, $website_codes));
        if (count($website_codes) !== count($website_ids)) {
            $diff = array_diff($website_codes, array_merge(array_values($code_map), array_keys($code_map)));
            $this->log("Unknown websites (skipped): ", join(", ", $diff), "error");
        }
        foreach ($website_ids as $website_id) {
            if (count($prices)) {
                $sql = "INSERT INTO $table (product_id, currency, website_id, price) VALUES " .
                    join(",\n", array_fill(0, count($prices), "(?, ?, ?, ?)")) . "\n" .
                    "ON DUPLICATE KEY UPDATE `price`= VALUES(`price`)";
                $bind = [];
                foreach ($prices as $price_currency_set) {
                    list($price, $currency) = $price_currency_set;
                    $bind[] = $sku;
                    $bind[] = $currency;
                    $bind[] = $website_id;
                    $bind[] = $price;
                }
                $this->insert($sql, $bind);
            }
        }
        return true;
    }
public function processItemAfterId ( & $ item , $ params = null ) { $ sku = $ params [ " product_id " ] ; $ table = $ this -> tablename ( " catalog_product_compound_price " ) ; $ prices = $ this -> getPrices ( $ item ) ; $ code_map = $ this -> _websites ; $ website_codes = [ " admin " ] ; if ( isset ( $ item [ " websites " ] ) && ! empty ( $ item [ " websites " ] ) ) { $ website_codes = preg_split ( '/,\s*/' , $ item [ " websites " ] ) ; } $ website_ids = array_filter ( array_map ( function ( $ code ) use ( $ code_map ) { if ( isset ( $ code_map [ $ code ] ) && ! is_numeric ( $ code ) ) { return $ code_map [ $ code ] ; } else if ( is_numeric ( $ code ) && in_array ( $ code , array_values ( $ code_map ) ) ) { return $ code ; } return null ; } , $ website_codes ) ) ; if ( count ( $ website_codes ) !== count ( $ website_ids ) ) { $ diff = array_diff ( $ website_codes , array_merge ( array_values ( $ code_map ) , array_keys ( $ code_map ) ) ) ; $ this -> log ( " Unknown websites (skipped):  " , join ( " ,  " , $ diff ) , " error " ) ; } foreach ( $ website_ids as $ website_id ) { if ( count ( $ prices ) ) { $ sql = " INSERT INTO  $ table  (product_id, currency, website_id, price) VALUES  " . join ( " , \n " , array_fill ( 0 , count ( $ prices ) , " (?, ?, ?, ?) " ) ) . " \n " . " ON DUPLICATE KEY UPDATE `price`= VALUES(`price`) " ; $ bind = [ ] ; foreach ( $ prices as $ price_currency_set ) { list ( $ price , $ currency ) = $ price_currency_set ; $ bind [ ] = $ sku ; $ bind [ ] = $ currency ; $ bind [ ] = $ website_id ; $ bind [ ] = $ price ; } $ this -> insert ( $ sql , $ bind ) ; } } return true ; }
you can add/remove columns for the item passed since it is passed by reference
 @param unknown_type $item
            : modifiable reference to item before import
            the $item is a key/value array with column names as keys and values as read from csv file.
you can add / remove columns for the item passed since it is passed by reference @param unknown_type $item : modifiable reference to item before import the $item is a key / value array with column names as keys and values as read from csv file .
// catalog_product_compound_price_product_compound_price // catalog_product_compound_special_price // Unpack website codes // Convert to IDs and remove unknown values // If unknown values were removed log it // Make an insert for each website