How to get quote_id from sales order page of admin in magento? - magento

Is it possible to get quote_id of an specific order in admin->sales->orders->view(select particular order) page ?
I want to show my custom table(which contain quote_id for an order) data in admin->sales->view(select particular order) gift option block.

Yes, the order itself has quote_id, you can retrieve it in this way:
// supposing order id is 1
$order = Mage::getModel('sales/order')->load(1);
$quoteId = $order->getQuoteId();
if you need to retrieve quote object, you can get it by:
$quoteObject = Mage::getModel('sales/quote')->load($quoteId);

Related

How to show region specific products magento?

how to show products in Magento based on selected state and city? is
there any extension available for this feature? or how can i achieve
this?
You can add one (city) or two (state and city) attributes in product model (by back-office panel).
Your news attributes can be contain the list (in example string with delimiter commas) with the list of state/city where the product is allowed to be sell.
For retrieve your state/city allowed list you can :
<?php
// id product is 12345
// the city allowed list attribute code is 'city_list'
$id = 12345;
$product = Mage::getModel('catalog/product')->load($id);
$cityList = $product->getAttributeText('city_list');
var_dump($cityList);
Output something like this :
string(38) "Los Angeles, New Delhi, Caen, etc, etc"
It's possible that you may be add ->getAttributeToSelect('city_list') after load($id) if the attribute isn't retrieve by catalog/product model.

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.

How can i get the parent_item_id on a simple product that's associated to a grouped product

How can i get parent_item_id on a simple product ?
This give as result: Array
$simple_product_id = $_product->getId();
$grouped_product_ids = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($simple_product_id);
echo $grouped_product_ids
Japs.
According to magento Methodology ,a simple can be added associated with multiple Groups products.Magento give result of this code in array format.
If your Simple Product is associated with one group product.then getting group product id try below code
echo $grouped_product_ids[0]

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

Discount for particular customer group in magento

I met with a requirement for my magento project, according this I need to provide special discount to specific customer group on their purchase. This discount must be shown in customer account,if they belong to that particular group, and when user want to use that particular discount, price of that item must be discounted according to that discount offer to them.
I know how to create a customer group, but how can I give them desired discount and make it show at time of purchase. so that customer can use it.
please suggest me any method or refer any document.
Thanks!
Since you want a discount to show "at time of purchase", use a Shopping Cart Price Rule from the Promotions menu. It can be restricted to certain customer groups.
A customer's group can be set by editing their account from Customers > Manage Customers menu, then look in Account Information for the Customer Group control.
The links I gave are both from the Magento User Guide. Please read it all.
http://www.magentocommerce.com/wiki/welcome_to_the_magento_user_s_guide/welcome_to_the_magento_user_s_guide
<?php
/**
* Get the resource model
*/
$resource = Mage::getSingleton('core/resource');
/**
* Retrieve the read connection
*/
$readConnection = $resource->getConnection('core_read');
/**
* Retrieve current users groupId
*/
$currentUserGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
/**
* Creating the custom query to fetch coupons
*/
$query = '
SELECT sr.rule_id, sr.name, sr.is_active, src.code, src.expiration_date
FROM `salesrule` sr
JOIN `salesrule_coupon` src ON (sr.`rule_id` = src.`rule_id`)
JOIN `salesrule_customer_group` scg ON(scg.`rule_id` = src.`rule_id`)
where scg.customer_group_id = '.$currentUserGroupId.'
AND sr.is_active = 1
AND ( ( src.expiration_date is null ) or ( src.expiration_date > now() ) )
';
//store result set in $rules
$rules = $readConnection->fetchAll($query);
// $rules will contain the array of all the coupons available to the current user
// This array contains all the data required
print_r($rules);
?>

Resources