In the xml to be imported each node has a SKU, a characteristic label and its value. A SKU has multiple characteristics so there are multiple nodes for the same SKU. I want to add the characteristics in the description field of each matched product. But I don't know how I can append each characteristic to a new line every time a product is matched by the sku. And how I can delete the description in the first occurence of the SKU in order not to have huge repititive description...
Here is a part of the xml:
<chars>
<product>SKU1</product>
<atribute>Label1</atribute>
<value>Value1</value>
</chars>
<chars>
<product>SKU1</product>
<atribute>Label2</atribute>
<value>Value2</value>
</chars>
<chars>
<product>SKU2</product>
<atribute>Label21</atribute>
<value>Value21</value>
</chars>
<chars>
<product>SKU3</product>
<atribute>Label31</atribute>
<value>Value31</value>
</chars>
<chars>
<product>SKU3</product>
<atribute>Label32</atribute>
<value>Value32</value>
</chars>
<chars>....</chars>
Given this example I want product with SKU1's description:
Label1:Value1
Label2:Value2 etc.
Related
I'm trying importing product with Import feature woocommerce
Here the CSV data:
post_title, type, category_ids, regular_price
Intel - Pentium G3250,simple,intel|1155|processors,860000
The issues is products that are imported, do not fit the category that writed on CSV Data.
I tried tax:cat header and still not get the result that i wanted, is that header column documentation is out of date or something? documentation
This is the screenshot
I'm solved this issues with changing delimiter csv from comma( , ) sign to semicolon( ; )
I realized that to add multiple cat on product cat is use comma to separated cat like this: cat1,cat2,cat3
so My csv look like this:
post_title; type; category_ids; regular_price
tes produk;simple;car,red,machine;860000
Hope it helps :)
I used Value Replacer and Clumn Mapper to set product status (enabled/disabled) but i have no effect in my magento!
Here my settings. Somebody have the same problems?
CSV content is:
nr;rack;
10001-52;Yes;
10001-55;No;
To use magmi, first i need convert the data to this correct content:
sku;status;
10001-52;1;
10001-55;2;
I use this plugins settings to convert the data:
Column mapper
Mapped columns list:nr,rack
nr = sku
rack = status
Value Replacer
Replaced attributes: Yes,No
Yes=1
No=2
(For magento "product status" disabled or enabled)
Magmi settings
CSV separator is: ;
CSV Enclosure: i leave it blank
Multiselect value separator: ;
Thank you so much!
Tommy
I have to make an array with the POSTED value of one SELECT. The SELECT selects the products ONE BY ONE. First I choose one product and POST it then another product and I POST the SECOND ONE and so on.....
I want to create an array of the ID of the products that are posted by the SELECT but this array has to grow while I introduce more and more products.
I have use this but It makes the array with only the last product I have choosen.
foreach($_POST['idproducto'] as $key => $val) {
$cadenaides = $cadenaides . "$val,";
}
$cadenaides = $cadenaides . 1;
I would like the array to have all the ID of the products I choose ONE BY ONE in the SELECT.
Seems to me like you want to assign a number to each posted value. You can do this like so:
foreach(...) {
$cadenaides[] = $val;
}
Your values will the be stored in an array. You can check your array with print_r($cadenaides);.
Reading the comments above and assuming that you use MySQL I would suggest the following:
SELECT GROUP_CONCAT(id_producto SEPARATOR ',') FROM producto WHERE .... put your conditions here ..;
This will concatinate all IDs in a single string like that 1,2,3,5,8,9... in a single result, after that you can do just one POST request. Very usefull in many cases BTW.
The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. Could be very large - max: 4294967295 for 32-bit system.
Say I have the following entity called inventory:
I would like to know if there are database, sql or magento actions or any other methods to produce:
I have solved this by iterating through the entire collection and inserting into a temporary table : i.e
$inventorySet = Mage::getModel('custom/module')->getCollection(*);
foreach($inventorySet as $item)
{
$this->insertItem($item->getSku());
}
}
public function insertItem($sku)
{
//insert sku if it does not exist in the temp set
// if it does exists add one to the QTY field
}
I can then retrieve what I want. I don't see an issue with it, but my entity is a lot larger than the example as well as the set of data containing anything between 2000 - 15 000 rows. is there not a more efficient way of doing this?
EDIT: In words, I would like to search the collection for occurrences of the "sku" field and return an array of unique sku's and the number of times it was found in the initial collection.
To get a particular set of column values from a collection you can use the getColumnValues() method.
For example, using a Magento product collection, this would return an array containing the sku attribute value for every product:
$collection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('sku');
$skus = $collection->getColumnValues('sku');
Finally, to answer the second part of your question, to count the occurence of each unique value:
array_count_values($skus);
This will give you a nice associative array of sku => occurrence count.
The taxonomy system changed a lot since Drupal 6. What is the best way to get all taxonomy term IDs associated with a single node in Drupal 7?
$node = node_load($nid);
$terms = field_view_field('node', $node, 'field_tags', array('default'));
Where do you want to get these terms ? In a module, a theme ...?
Did you take a look at :
http://api.drupal.org/api/drupal/modules--taxonomy--taxonomy.module
The field_data_field_tags table just covers the default Tags field, that might or might not exist and you might have other taxonomies too.
However, taxonomy.module still maintains the taxonomy_term_data/taxonomy_index tables which you can query:
SELECT tid FROM {taxonomy_index} WHERE nid = :nid
Or if you want a specific vocabulary ID:
SELECT ti.tid FROM {taxonomy_index} ti INNER JOIN {taxonomy_term_data} ttd ON ttd.tid = ti.tid WHERE ti.nid = :nid AND vid = :vid
Completely untested.