How can i Export only first 100 products from magento using magento inbuilt data flow profile functionality. i want to export first products but there are 20000 products there on my store so i want to export products in bunch of 1000.Waiting for suggestion.
You can do it by rewrite the core function getIdCollection() inside Mage_Dataflow_Model_Batch_Abstract class.
There is return all id collections, you can customize code there as you need it.
Currently return code as per following:
return $this->getResource()->getIdCollection($this), you can replace code as per following
//return $this->getResource()->getIdCollection($this);
$idArray = array();
foreach($this->getResource()->getIdCollection($this) as $key => $val){
if($key < 100){
$idArray[] = $val;
}
}
return $idArray;
After Please check downloaded csv, don't see loaded records on popup window Hope this would help you!..
Related
Maybe this is already answered somewhere else, but I couldn't find it after researching for 5 days.
I've a custom WP Query that returns products for JavaScript AJAX client. My client wants to handle the "number of rows" and "columns" through wooCommerce config that is available through customization of shop page.
Here's my basic implementation for custom WP Query:
function loadProducts(){
// Access the number of rows and columns input here from customization page??
}
add_action("wp_ajax_loadprods","loadProducts");
add_action("wp_ajax_nopriv_loadprods","loadProducts")
From the ref: /wp-content/plugins/woocommerce/includes/wc-template-functions.php
function loadProducts(){
$columns = get_option('woocommerce_catalog_columns', 4);
$rows = absint(get_option('woocommerce_catalog_rows', 4));
echo json_encode(array('columns' => $columns, 'rows' => $rows));
wp_die();
}
add_action("wp_ajax_loadprods","loadProducts");
add_action("wp_ajax_nopriv_loadprods","loadProducts")
I am importing google contacts from a csv file in a specific manner, in the file I have 2 custom fields that need to be added to every contact when they are imported. I have added the first custom field but have no idea how to add a second one programatically. It seems possible as you can add a second custom field from the contact page. Here is the code to add one custom field to the contact:
$opened_file=fopen("export_test.csv", "r");
while(($data = fgetcsv($opened_file, 1000,",")) !== FALSE)
{
$contacts[] = $data;
}
$person = new Google_Service_PeopleService_Person();
$custom_field = new Google_Service_PeopleService_UserDefined();
for($i = 1; $i < count($contacts); $i++)
{
$custom_field->setKey($contacts[$i][50]);
$custom_field->setValue($contacts[$i][51]);
$person->setUserDefined($custom_field);
}
I have tried making a new user defined object, setting the key and value and attaching it to the person but this just overwrites the first custom field. I have also looked this issue up but turned up with nothing. Is it possible to add a second custom field programatically?
UserDefined is a list in the documentation https://developers.google.com/people/api/rest/v1/people#resource:-person.
I'm unsure about the PHP syntax, but based on examples in https://github.com/googleapis/google-api-php-client, try doing
$custom_field_array = array();
...
$person->setUserDefined($custom_field_array);
Hello gods of Stackoverflow,
Now i hate to be "that guy" who didnt search properly but i am running into a problem that i need a fix for and can't find a solution i can work with because of my lack in coding skills, my knowledge barely tickles the surface.
Here's the thing.
I am using a tool to import feeds into my website (WP all Import) as woocommerceproducts. But in the categorization the feed suppliers made errors which i want to tackle without emailing them everytime i stumble upon one.
i.e: the title contains words like satchel, bag, clutch etc but the product is categorized as 'jewellery > earrings' in the CSV or XML.
The import tool will ask me where to find the product category, i point it to the node {category[1]}
But when the category is missing or faulty i want it to check the title for certain words, and if present change the value of it to that found word.
something like:
[if ({title[1]}contains "satchel") {
category = "bags > satchel",
} else if ({title[1]} contains clutch) {
category = "bags > clutch",
} else {
category = {sub_category[1]} #the normal value if nothing was found
}]
I just can't find the pieces to put the formatting together. I might need to work towards a function that i could expand to generate categories based solely out of presence of certain words in the title but maybe when i get better that would be an option.
I hope i was able to provide a clear view on the problem. The "[ ]" is there because thats how the plugin wants code to be entered instead of a {fieldname[1]}, another example below:
The following was an example of a problem i was able to fix:
i needed to replace values like "0/3months/1/2months" to "0-3 months/1-2months" before i replaced the slash"/" with a pipe"|" for wordpress to recognize it as a seperate value.
[str_replace("/","|",
str_replace("0/3","0-3",
str_replace("1/2","1-2",
str_replace("3/6","3-6",{size[1]}))))]
The fields can also be used to call functions but only in the 'pro' version of the plugin.
Any help is very much appreciated, thanks in advance.
You could use strpos.
Example:
if (strpos($title, "satchel") !== false) {
$category = "bags > satchel";
}
So after an afternoon of poking around, testing stuff, and not knowing alot about php i came up with a solution with help from a friend.
Wp All Import does not allow custom php directly from the field itself, it does however support custom php functions and provides an editor for these on the bottom of the import configuration page. I did the following:
<?php
//Checks Title for keywords and
//uses those to create categories
//We are using our own Main categories so only
//sub and subsub categroies need to be created.
//Call function
[get_subcat_from_title({title[1]},{category[1]})]
//Function
function get_subcat_from_title($title,$defaultcat)
{
if (strpos($title,"Satchel") !== false) {
$cat = "Tassen";
} elseif (strpos($title,"Travel") !== false) {
$cat = "Tassen";
} elseif (strpos($title,"Gusset") !== false) {
$cat = "Tassen";
} else {
$cat = $defaultcat;
}
return $cat;
}
//Checks Title for keywords and uses those to create subcategories
//Call Function
[get_subsubcat_from_title({title[1]},{sub_category[1]})]
//Function
function get_subsubcat_from_title($title,$defaultcat)
{
if (strpos($title,"Satchel") !== false) {
$cat = "Satchel";
} elseif (strpos($title,"Travel") !== false) {
$cat = "Travel";
} elseif (strpos($title,"Gusset") !== false) {
$cat = "Gusset";
} else {
$cat = $defaultcat;
}
return $cat;
}
?>
On the Taxonomies, Tags, Categories option we can create our own hierarchical order like this:
[main category]
+[sub category]
++[sub sub category]
The main category field is given a name we use as our main category.
The sub category is filled with function SUBCAT
The subsub category is filled with function SUBSUBCAT
this way it will create a parent by our own name, a child that has the named 'Tassen' if any keyword is present, and a grandchild with the specific keyword as it's name.
This way i can expand the function using all kinds of statements when the right category isn't present in de provided feed.
thanks #sebastianForsberg for responding.
I hope this helps anyone who comes across a similar problem in the future..
I've been looking for this like everywhere now ;)
I want to add the product image to the popup, but I can't figure out how to achieve this!
I've been searching for hours and hours now and next to that tried to code this myself but it won't work.
So now I'm asking for help... if anyone has some ideas on this please let me know.
Afaik there's more people on the net that would like to see a "add to cart"-popup with some more informations given on it.
Sincerly Thomas
I just recently customised the add to cart popup on a site myself. The file you need to edit is components/com_virtuemart/controllers/cart.php (the function is called addJS if I remember correctly).
You can find the API documentation for VirtueMart here: http://docs.virtuemart.net/api-vm2/ however I wrote my own plugin to fetch the VM data.
Then you can just use standard PHP rather than getting your head round the VM API.
If you decide to do it my way you can call custom classes from your plugin and output the image like so:
$cart_image = plgMyCoolPlugin::_getImage($this->product->virtuemart_product_id);
echo '<img src='.$cart_image.'/>';
Remember you need to import your plugin type if you don't make it a system plugin:
JPluginHelper::importPlugin( 'mynewplugintype' );
Here's the function I use in my plugin:
function _getImage($id)
{
$db =& JFactory::getDBO();
$sql = " SELECT
b.`file_url`
FROM
".$db->nameQuote('#__virtuemart_product_medias')." AS a
INNER JOIN
".$db->nameQuote('#__virtuemart_medias')." AS b ON a.`virtuemart_media_id` = b.`virtuemart_media_id`
WHERE
a.".$db->nameQuote('virtuemart_product_id')." = ".$id."
AND
b.".$db->nameQuote('file_mimetype')." = 'image/jpeg'
AND
b.".$db->nameQuote('file_type')." = 'product'
AND
b.".$db->nameQuote('file_is_forSale')." = '0'";
$query = $db->setQuery($sql);
$row = $db->loadResultArray();
if($db->getErrorNum()) {
JError::raiseError( 500, $db->stderr());
}
if(empty($row)) $row[] = JURI::base().'images/defaultimage.jpg';
return $row;
}
Hope this helps :)
I'm new to opencart and i created a module like latest module in opencart but the difference is the only latest module show latest product and my module is for all product and showing product in random manner. this my module is working fine..but there is a problem occurs for show the actual rating for each product..Now i want to add rating system in my module.
So i want to know that whta should be the right query of mysql to get all product info like name,description,reviews,ratings,product_id etc..
you haven't shown your approach so its just general pointers
first you load product.php model in your controller file $this->load->model('catalog/product');
then you decide what would be your filters when calling getProducts if you don't give any filters it will return all products in database, lets say you decide no filters then just pass an empty array of data (or don't pass anything at all )
$data = array();
then you call the function
$results = $this->model_catalog_product->getProducts($data); //or without $data
now you can do something like
foreach ($results as $result) {
$this->data['products'][] = array(
'product_id' => $result['product_id'],
'name' => $result['name'],
'rating' => $result['rating'],
);
now you can use that in your tpl file like
<?php foreach ($products as $product) { ?>
some code here
<?php echo $product['rating']; ?>
<?php } ?>
this is the generic way you should use, and its easy too, if you know how that getProducts function takes data out from database and return result see getProducts function in catalog/model/catalog/product.php