How to import Group price in magento through csv? - magento

I need to import wholesale price and retail price both for each products in my website
so I tried to create test product with group price and export that.
and with those fields tried to import, I tried that using both "import" and "dataflow/import", in all case I am getting import successful message , but actually not imported that group prices

By default Magento Import doesn't support for this.
You can either use the custom code as:
// add a pricing to store 1
$product = Mage::getModel('catalog/product')->setStoreId(1)->load(1234);
$product->setData('group_price',array (
array (
"website_id" => 1,
"cust_group" => 2,
"price" => 105
)));
$product->save();

Related

Using Magento API to add all products to root category

I want to set all the products to the root category (next to the current category they are in).
I know the best way to do this is using the Magento API, but can somebody get me started on this?
Just to be clear, i don't want to change the category id, i just want to add another category id to the product.
EDIT
It takes a lot time to check all 3000+ products to see in what other category it is. Example: Root_catId = 175 Product_1 cat = 3 (needs to be: 3, 175) Product_2 cat = 9 (needs to be: 9, 175)
You can do this without using the API but if you want to use the API try following.
You can use following first you need to create a user with permissions to access soap requests in Magento admin
<?php
$proxy = new SoapClient('http://yourmagento/api/v2_soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$result = $proxy->catalogCategoryAssignProduct($sessionId, '3', '10'); // 3 is category id and 10 is product id
You can loop through every product to assign the product to a specific category.
Replace the root category id with the category id which you require.

load product using custom attribute as well as if product qty is greater then 0 in magento?

Am trying to do special offers to my magento shop.Actually that is easy but actually my scenario is differs from others.My scenario is,I must get the products based on custom attribute(date of sale) and as well as product qty must be greater than zero(Qty>0).I got the products using custom attribute like,
<?php
$collection = Mage::getResourceModel('catalogsearch/advanced_collection')
->addAttributeToSelect(Mage::getSingleton('catalog/config')- >getProductAttributes())
->addMinimalPrice()
->addStoreFilter();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection);
$collection->addAttributeToFilter('date_sale', array('lt' => $todayDate));
return $collection;?>
On this i got the products based on date of sale is lesser than today date.On that itself i must get products which qty is greater than 0.
give me some hopes guys?
After the filter use another addAttributeToFiler('attribute code of inventory quantity',array('gt' => 0));
This acts as AND filter
You can check 'and' and 'or' filter here OR and AND STATEMENT addAttributeToFilter magento asnd use according to requirement.

Magento Bundle Product - Multiple Options with Same products. How to stop Magento from hiding the repetitive products?

I am trying to setup a bundle product within Magento. This product should allow the customer to select 4 free products to include with the bundle. These products can be all different or 4 of the same product.
For example
Free Product 1
Free Product 2
Free Product 3
A customer could select four of Free Product 1, or one of Free Product 1 & 2, with two of Free Product 3.
I am using 4 drop-down input types which each have all three Free products as options. So a customer can choose any of the three products for each Free Gift line item.
Magento is only displaying one of the drop-down select lists, I believe due to the fact that each drop-down contains the same product list.
Where would I need to look to stop Magento from checking if the product options are already listed in a previous selection?
Unless you're doing this programmatically (that is writing the code), there's no way to do this.
When Magento adds a product, it first looks into the quote / shopping cart to see if one already exists. If one does, it pulls that one and adds to the quantity. There is no way to turn this off.
Programmatically, you very manually add an item to a shopping cart. This is how...
$cart = Mage::getSingleton("checkout/cart");
foreach ($products_to_add as $product_id => $custom_options) {
$product = Mage::getModel("catalog/product")->load($product_id);
$options = new Varien_Object(array("options" => $custom_options,
"qty" => 1));
// some products may result in multiple products getting added to cart
// I beleive this pulls them all and sets the custom options accordingly
$add_all = $product->getTypeInstance(true)
->prepareForCartAdvanced($options, $product, Mage_Catalog_Model_Product_Type_Abstract::PROCESS_MODE_FULL);
foreach ($add_all as $add_me) {
$item = Mage::getModel('sales/quote_item');
$item->setStoreId(Mage::app()->getStore()->getId());
$item->setOptions($add_me->getCustomOptions())
->setProduct($add_me);
$item->setQty(1);
$cart->getQuote()->addItem($item);
}
}
// when done adding all the items, finally call save on the cart
$cart->save();

Magento: Import product prices for an additional website?

I have a Magento installation, with two websites on it:
Retail (default)
Trade
Currently all the prices have been imported as default and so the prices are set the same on both websites. I now need to import the lower prices just for the trade website.
I know this can be done manually per product, but how do I go about importing these prices (with their SKU's so that they only apply to the trade store?
Any help much appreciated!
I suggest doing a Product Export first so you can see all of the columns that are used. Locate a SKU from your Trade store and see what the values are for that column.
You should see a column called _product_websites. In my installation, this column has "base" in it. On yours it will probably say "base" and "trade" (whatever you specified for your website code). You can sort by this column in Excel or other spreadsheet software and remove all of the rows that just have "base" in it so you're left with "trade". Now you can update your prices, save the sheet and re-import your file.
hth
You can simply follow the following Magento blog post:
http://www.blog.magepsycho.com/updating-product-prices-in-magento-in-easier-faster-way/
Just you need to add store_id filter in following method as:
function _updatePrices($data){
    $connection     = _getConnection('core_write');
    $sku            = $data[0];
    $newPrice       = $data[1];
$storeId = $data[2];
    $productId      = _getIdFromSku($sku);
    $attributeId    = _getAttributeId();
 
    $sql = "UPDATE " . _getTableName('catalog_product_entity_decimal') . " cped
                SET  cped.value = ?
            WHERE  cped.attribute_id = ?
            AND cped.entity_id = ?
AND store_id = ?";
    $connection->query($sql, array($newPrice, $attributeId, $productId, $storeId));
}
Of course you need to use third column of prices.csv for store_id.
Let me know if that helps.

How to get Product id using Super attribute in Magento?

I am working on ajax module for Shopping cart in Magento. Consider i have a configurable product with 2 simple products configured as its two sizes (Small an Medium). When user selects and adds the item to cart, i cannot see the specific product id (small) in the url.
But instead supper_attribute is posted to my controller.
Is it possible for me to get the actual product id of size "Small" with the super attribute.
Below is my supper attribute array
[super_attribute] => Array
(
[129] => 128
)
129 = attribute_id (Size)
128 = attribute value (Small)
Please suggest me in this scenario. Please let me know if my question is not clear.
Thanks
Try this:
$childProduct = Mage::getModel('catalog/product_type_configurable')->getProductByAttributes($request->getData('super_attribute'), $product);
Where $product is the configurable product object.
For the Class Reference

Resources