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'));
Related
I'm so beginner in Prestashop 1.7, I wanted to add a dropdown select section in my banner module to select the way to open the banner link.
but the selected value is never passed to the HTML, the code below IS passed but the one under isn't, can you please assist me?
[enter image description here][1]
array(
'type' => 'text',
'lang' => true,
'label' => $this->trans('Banner description', array(), 'Modules.Banner.Admin'),
'name' => 'BANNER_DESC',
'desc' => $this->trans('Please enter a short but meaningful description for the banner.', array(), 'Modules.Banner.Admin')
)
array(
'type' => 'select', //select
'lang' => true,
'label' => $this->trans('Banner tab', array(), 'Modules.Banner.Admin'),
'name' => 'BANNER_TAB',
'required'=>'true',
'options' => array(
'query' => array(
array('key' => '_blank', 'name' => 'New tab'),
array('key' => '_self', 'name' => 'Same tab'),
),
'id' => 'key',
'name' => 'name'
),
'desc' => $this->trans('Please select the way to open the link.', array(), 'Modules.Banner.Admin')
)
This is how it looks in the Backoffice:
Here
You not only need to add a new field to your form but also handle saving the data from it.
Take a look at a few examples:
https://github.com/PrestaShop/ps_featuredproducts/blob/dev/ps_featuredproducts.php#L122
Notice how the module author managed to save each configuration field from the form. This is what you need to do.
If you want to have access to data in your view, you have to pass it:
https://github.com/PrestaShop/ps_featuredproducts/blob/dev/ps_featuredproducts.php#L244
Maybe after you added a new field, you forgot to handle the saving + passing to the view?
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.
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.
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
I've created a custom node type in Drupal 7, using the hook_node_info method in the install file:
// declare the new node type
function foo_node_info ( ) {
return array(
'foo' => array(
'name' => t('Foo entry'),
'base' => 'node_content',
'description' => t('For use to store foo entries.'),
));
} // END function foo_node_info
and I'm trying to save that type in the module file using the following code:
// INSERT the stuff
node_save(node_submit((object)array(
'type' => 'foo',
'is_new' => true,
'uid' => 1,
'title' => 'Title, blah blah blah',
'url' => 'url here, just pretend',
'body' => '<p>test</p>',
)));
My issue, is that the url, and body fields aren't saving. Any idea what I'm doing wrong?
So, after a ton of digging, it turns out that the way I was entering the custom fields in the node_save was wrong. The node_save needs to look like the following:
node_save(node_submit((object)array(
'type' => 'foo',
'is_new' => true,
'uid' => 1,
'title' => 'the title',
'url' => array(
'und' => array(array(
'summary' => '',
'value' => 'url value',
'format' => 2,
))),
'body' => array(
'und' => array(array(
'summary' => '',
'value' => 'the body goes here',
'format' => 2,
))),
)));
Notice that for the custom fields, the array structure has to match what was previously going on with CCK (pretty much exactly). The first key in the array describing the field value is the language for the content.
I've used 'und' here only because that's what I saw going into the database when entering the data through a form.