Importing image from external URL using Magmi datapump - php

I am using Magmi datapump to import some products into Magento.
So far i have this:
require_once("../../magmi/inc/magmi_defs.php");
require_once("../../magmi/integration/inc/magmi_datapump.php");
$dp = Magmi_DataPumpFactory::getDataPumpInstance("productimport");
$dp->beginImportSession("Default","create");
$newProductData = array(
'type' => 'simple',
'sku' => "test-simple",
'qty' => 1000,
'color' => 'Brown',
'price' => 10,
'name' => 'test simple',
'tax_class_id' => 1,
'is_in_stock' => 1,
'store' => 'admin',
'economic_productgroup' => 700,
'image' => '+http://blogs.smh.com.au/entertainment/getflickd/44655_native.jpeg.jpg',
'small_image' => 'http://blogs.smh.com.au/entertainment/getflickd/44655_native.jpeg.jpg',
'thumbnail' => 'http://blogs.smh.com.au/entertainment/getflickd/44655_native.jpeg.jpg'
);
$dp->ingest($newProductData);
$dp->endImportSession();
All attributes are getting imported correctly, except image. This does not work.
This is screenshot from "Default" profile.
Magmi is installed here: http://www.example.com/import/magmi/web/magmi.php
Why are import of my images not working?

Problem solved by creating new profile in webinterface with exact same settings as i had in "default" profile. Not sure why though.

Related

"101: Product not exists." (Magento API) product.update

I saw the documentation but I still not finding the error on my code.
I am trying to add a product from excel file to Magento System, and then update it on each Store View (multi language shop).
For that, I've done the following PHP script. On this code, I'm reading only one Excel row (just to show you how it works) and then i am adding it to Magento (actually that's working) and then I am trying to Update stuff (gives the error). Be aware that $col[9] is the var that saves the SKU.
Note: I am using SOAP, but not V2.
$rowdata=$sheet->rangeToArray('A' . $row.':'.$maxcol . $row, NULL, TRUE, FALSE);
$col=$rowdata[0];
//$soap is the client. $session_id is the logged in SOAP session.
$attributeSets = $soap->call($session_id, 'product_attribute_set.list');
$attributeSet = current($attributeSets);
$result = $soap->call($session_id, 'catalog_product.create', array('simple', $attributeSet['set_id'], $col[9], array(
'categories' => array(2),
'websites' => array(1),
'name' => $col[1],
'description' => $col[10],
'short_description' => $col[13],
'weight' => '10',
'status' => '1',
'url_key' => 'product-url-key',
'url_path' => 'product-url-path',
'visibility' => '4',
'price' => $col[20],
'tax_class_id' => 1,
'meta_title' => 'Product meta title',
'meta_keyword' => 'Product meta keyword',
'meta_description' => 'Product meta description'
)));
var_dump ($result);
$updatearray= array(
'name' => $col[2],
'description' => $col[11],
'short_description' => $col[14]
);
$update = $soap->call($session_id, 'catalog_product.update', array($col[9], $updatearray, 'fr'));
var_dump ($update);
I would appreciate any help you guys can give!
I just found the fix for this problem but it really makes no sense.
So, when we are sending the SKU by call, we need to send with an extra space. It means the $update needs to be like this:
$soap->call($session_id, 'catalog_product.update', array($col[9].' ', $updatearray, 'fr'));

Import product with attributes magento

im using an import script that import's simple and configurable product to magento from xml.
The problem is that, imported simple products are i magento but they don't have attributes values assigned.
Import via APIv2 is working well bu it is to slow, that why i need to do this on model.
my question is:
Is This (code below) correct ? Meybe you have better, different metod to assigne attribute value to product :-)
$product->setData('rozmiar',$Products['sizeId']);
$product->setData('kolor',$Products['colorId']);
my code:
$productCheck = Mage::getModel('catalog/product')->loadByAttribute('sku', $products['sku']);
if ($productCheck) {
$productCheck->delete();
//print_r('true !');
}
$color = attributeValueExists1('kolor',$Products['color']);
$size = attributeValueExists1('rozmiar',$Products['size']);
$product = Mage::getModel('catalog/product');
$product->setCreatedAt(strtotime('now'));
$product->setTypeId($products['type']);
$product->setTaxClassId(0);
$product->setWebsiteIds(array(1));
$product->setAttributeSetId($products['attrset']);
$product->setSku($products['sku']);
$product->setName($products['name']);
$product->setDescription($products['description']);
$product->setInDepth('');
$product->setPrice($products['price']);
$product->setShortDescription($products['description']);
$product->setWeight(0);
$product->setStatus(1);
$product->setVisibility(1);
//$product->setMetaDescription($products['name']);
//$product->setMetaTitle($products['name']);
//$product->setMetaKeywords($products['name']);
$product->setCategoryIds($products['categories']);
$product->setKolor($color);
$product->setRozmiar($size);
//$product->setData('rozmiar',$Products['size']);
//$product->setData('kolor',$Products['color']);
$product->setStockData(array(
'use_config_manage_stock' => 0,
'manage_stock'=>1,
'min_sale_qty'=>1,
//'max_sale_qty'=>2,
'is_in_stock' => 1,
'qty' => $products['qty']
)
);
$product->save();
Importing products via Soap APIv2 im using
$result = $this->client2->catalogProductCreate($this->session, $type, /*$attributeSet['set_id']*/ '4', $kod, array(
'categories' => $kategorie, // array !!!!
'websites' => array(1),
'name' => $nazwa,
'description' => $opis,
'short_description' => $opis,
'weight' => '1',
'status' => '1',
'url_key' => $nazwa,
'url_path' => $nazwa,
'visibility' => '1',
'price' => $cena,
'tax_class_id' => 1,
'meta_title' => '',
'meta_keyword' => '',
'meta_description' => '',
'stock_data' => array( 'manage_stock' => '1',
'manage_stockSpecified' => False,
'is_in_stock' => '1',
'is_in_StockSpecified' => False,
'qty' => $ilosc
),
'additional_attributes' => $additionalattr
));
return $result;
Is additional_attributes different from $product->setData('rozmiar',$Products['sizeID']); ?
If it's not the same how can i add additional_attributes when importing products via catalog/product model ?
First you need to assign corresponding attributes to products. Then after you can use import script to save those attributes value to products.

Bigcommmere Api create product with images link

I want to create product in bigcommerce store using bigcommerce Api. Following code works fine to create product in Bc store
$product = array('name' => 'ABC Blocks', 'type' => 'physical', 'price' => '19.99', 'weight' => 2.3, 'categories' => array(26), 'availability' => 'available', 'is_visible' => true));
Bigcommerce_Api::createProduct($product);
How can I pass images url ? I am trying following codes but unable to create
$image = array('image_file'=>'https://developer.bigcommerce.com/assets/hero-image.png','is_thumbnail'=>false,'sort_order'=>1,'description'=>'');
$product = array('name' => 'ABC Blocks', 'type' => 'physical', 'price' => '19.99', 'weight' => 2.3, 'categories' => array(26), 'availability' => 'available', 'is_visible' => true,'images' => array('image_file' => $image));
Bigcommerce_Api::createProduct($product);
Any help will be greatly appreciated!!thanks
Here's an example structure from the api about how primary image data should look.
"primary_image": {
"id": 247,
"zoom_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.1280.1280.jpg?c=1",
"thumbnail_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.220.290.jpg?c=1",
"standard_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.386.513.jpg?c=1",
"tiny_url": "https://cdn.url.path/bcapp/et7xe3pz/products/32/images/247/in_123__14581.1393831046.44.58.jpg?c=1"
}
Use this to figure out your array structure.

Magento Cart_Product.Add Custom Options File Upload via Soap API

Can not achieve to upload a file via soap api to Cart. I want user to add a product to cart with a required custom option which is an image.
So spent hours, can not find any resource/documentation/same problem anywhere but actually figure out, soap api requires array (ok, but what are the parameters?) And It does not throw any error if something goes wrong (weird?)
So in practice what I am willing to achieve:
// Prepare image
$newImage = array(
'file' => array(
'name' => $_FILES['uploadedfile']['name'],
'content' => base64_encode(file_get_contents($_FILES['uploadedfile']['tmp_name'])),
'mime' => 'image/png'
),
'label' => $_FILES['uploadedfile']['name']
);
// Prepare product & Custom options
$arrProducts = array(
array(
'product_id' => '7',
'qty' => 1,
'options' => array ( '30' => $newImage ) // optionId_1 => optionValue_1
)
);
// lets do adding
$resultCartProductAdd = $client->call(
$session,
'cart_product.add',
array(
$quoteId,
$arrProducts
)
);
The problem is, the image is not uploaded to /media/custom_options/quote folder where should belongs to and when order complete can not see anywhere. As I mentioned, there is no error thrown while this process..
Thanks for helping me out.
Please try this....
$arrProducts = array(
array(
'product_id' => '7',
'qty' => 1,
'options' => array ( 'options_30_file' => $newImage,'options_30_file_action'=>'save_new' )
)
);
or
$arrProducts = array(
array(
'product_id' => '7',
'qty' => 1,
'options_30_file' => $newImage,
'options_30_file_action'=>'save_new'
)
);
Let me if any issue

Creating a new attribute does not update product flat data

I'm writing an import module to import configurable products into magento, which works quite fine. I've tweaked the import so that it can create all necessary attribute sets, attributes and attribute options needed for creating the configurable products. So far everything works ... quite everything.
When the import creates a new attribute, it can not create the configurable product. When I edit the new attribute in the backend and save it without changes, a message appears which tells me to update some indexes. After I have updated the product flat data index, I can run the import again and everything works fine.
I've tried to ways to create a new attribute:
$setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
$setup->addAttribute(
$this->getEntityTypeId(),
$code,
array(
'attribute_code' => $code,
'label' => ucfirst($code),
//'group' => $attributeSet->getId(),
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'input' => 'select',
'unique' => 0,
'required' => 0,
'configurable' => 1,
'filterable' => 1,
'visible_on_front' => 1,
'used_in_product_listing' => 1,
'frontend_label' => array(
$code
)
)
);
The other way is:
$attribute = Mage::getModel("catalog/resource_eav_attribute");
$attribute->addData(
array(
'entity_type_id' => $this->getEntityTypeId(),
'attribute_code' => $code,
'label' => ucfirst($code),
//'group' => $attributeSet->getId(),
'is_user_defined' => 1,
'is_global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'frontend_input' => 'select',
'is_unique' => 0,
'is_required' => 0,
'is_configurable' => 1,
'is_filterable' => 1,
'is_visible_on_front' => 1,
'is_used_in_product_listing'=> 1,
'frontend_label' => array(
$code
)
)
);
$attribute->save();
Both codes create the attribute well but I can't use it to create configurable Attributes. I've tried to manually run the index scripts but this does not help me.
What am I doing wrong? Is creating new attributes somehow the black magic of magento? :-D
I forgot to set the backend type for the new attribute to "int" so it was automatically set to static (which means magento looks for it in the entity table).
The other thing is that i couldn't set the attribute value like this:
$model->setData("newattributecode", 123);
Magento just didn't save the attribute. Instead I had to use the undocumented function Mage_Catalog_Model_Product::addAttributeUpdate() to save the attribute value of this model:
$model->addAttributeUpdate("newattributecode", 123, 0);

Categories