Magento use final_price in a php script - php

Question regarding Magento:
I need to make a PHP script where I grab the ‘final_price’ (the price after applying category and shopping cart price rules), of a product for a particular customer group, and use this in a calculation to populate a specific attribute with the outcome.
Example:
Product ‘X’ has a ‘price’ attribute set at $100 in Magento
After applying the category price rules for customer group ‘CG’, the final_price for product ‘X’ for this specific customer group is $10
Next, I populate the (self-created) attribute ‘price grabbed’ = (final_price for product group CG) * ( 1.56 ) = $15.60
The script needs to make the above calculation for each of the products
I have been searching all over the place how to use final_price for a specific customer group in a PHP script in Magento CE 1.7.2, but can’t find a proper method. The idea is to call the script nightly through cron.
I have full access to Magento, the dedicated (Centos 5, LAMP) server, and all databases. The database has 15000 products.
Does anybody have an idea how I best do this?
Regards,
Jan

What is used in the product to determine the customer group is
Mage::getSingleton('customer/session')->getCustomerGroupId();
So what you want to do is to ensure that you set the customer group id in the customer session before calling the getFinalPrice() method on the catalog/product model.

Related

CS Cart Specific price per user group

Is it possible to add second price to each product and use that price if user in specific usergroup?
I was thinking doing that by adding another column to the product price table and then take advantage of the promotion function to somehow use that price instead of the usual discount you can set from admin.
Any pointers or ideas would be great, thank you.
Yes, it is possible to define price for product that is valid/shown only for users in specific usergroup.
To achieve this you need to use Quantity discounts tab on Editing product page.
Name of this tab implies as there must be some large amount of items bought (like volume discounts...), but quantity can also be just 1 item.
For this you first need to define usergroup (Customers->User groups).
Example is shown also on CS-Cart Knowledge base: Wholesale Prices
Best regards,
Bostjan
It is default CS-Cart feature. Please check the following article in the database:
http://kb.cs-cart.com/wholesale-prices

Getting product weight info in virtuemart inside order details/order history page

I have the following problem in virtuemart:
I have made a function to calculate shipping cost based on a five stage cost given by the shipping company. This works perfectly on the cart page, but on the order details and order history page it does not, as I cannot get the product weight in these pages.
I have looked into order_items.php where the order details references are kept, but there is no reference to the product weight, only to product id, quantity, category, etc.
Could anyone help me in how to get the product weight inside the order details page? I can do the rest in calculating the shipping rates and updating the final sales price, but I am stuck in getting this info.
Any help is welcomed :)
Try this,
I think you missed something about order tables, hope you are using VM2.x
In this version once the order is processed its payment,shipment information gets saved on the #__orders table.
In additionally the payment method Id and Shipment method Id also gets saved. So you can identify the method used on the order.
The idea of calculating ordered products shipping cost later on admin side is not practical bcoz later the shipping cost may very.
So practically once the user placed an order that time you have to save these information on the above table. If you're using VM default Shipping plugins they will do this by default.
Hope its clear.

Restricting customers to max of 2 purchases for a certain product in Magento

I currently have an issue trying to restrict customers to purchasing 2 of a product max.
So far, I can set the max number of the product in the cart to 2 using catalog/manage products, select the product, then inventory and adjusting the max Qty allowed in cart to 2.
However, this will not stop the user coming back another day and purchasing another 2 items.
What I would like to do is create a rule so that when the user logs in and tries to purchase the product, after already purchasing it, the code will throw an error saying that they have reached their max quantity and prevent the cart from processing the order.
I believe that I would have to edit one of the php files to run a check against the users id and the product id, but I am unsure which file will need to be edited.
Magento ver. 1.3.2.4
Links that helped me, hope it helps:
step 1
step 2
First of all create one observer checkout_cart_add_product_before
In this observer event check cart quantity of product, you can get qoute item from quote object and from quote retrieve product quantity and match with newly added product if condition satisfied then redirect customer to product details page with mesage
To support future compatibility and prevent your changes from being overwritten you should create a custom extension that hooks into the core.
You might try the hook: checkout_cart_add_product_complete or checkout_cart_add_product_before and test the number of items of each product. Based on that result you might automatically remove the item and parse an error.

Auto switch customer group in magento

Has anyone found a way to auto switch a customer group based on specific rules? For example, if a customer over their lifetime has ordered 200 plus bottles of something they are grouped in a specific customer tier and get special pricing (wholesale type situation)
I know how to do segments of customers but that doesn't help me auto change which customer group they belong too.
Thanks in advance for any help in the right direction...
there are a couple of payable extensions at magento connect or you can create simple module with custom actions. Article for a good start.
In case someone is still looking for an answer, this extension (which I created) can do exactly what you are looking for and more out of the box:
Website:
https://plugin.company/magento-extensions/automatic-customer-group-switching.html
On Magento Connect:
http://www.magentocommerce.com/magento-connect/automatic-customer-group-switching-by-plugin-company.html
If you'd like to build your own custom functionality though, I'd recommend looking into the sales_order_placed_after event and getting the order history details by filtering an order collection on the customer ID that has placed the order.
Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $yourCustomerId);
You can then loop through each order and get all items by using the getAllItemsmethod.
Alternatively you could retrieve a sales_order_item collection, and join the corresponding order details from the sales_flat_order table. Then you could filter on customer ID and product ID and group the results on product ID.
You can then base your customer group switching logic on the sum of the total ordered product quantity.

How can i get products displayed with predefined quantities in magento?

I have some simple products setup that have various custom options, some of which are set to required. What I would like to do is get the products set up to where the customer can choose from predefined quantities for a certain price.
For example say the product is a widget, i want the customer to be able to choose from say 100 for $20, 200 for $35, 500 for $80 ..... and so on.
Tiered Pricing doesn't work since the prices are increasing.
I tried using a custom options which worked out price-wise BUT it did not update the total weight of the product which I need calculated in order to calculate shipping quotes.
I also tried using group products and setting the products within the group as the specific quantities and setting the calculated weights BUT it doesn't allow me to keep the custom options i have set as required.
So right now I'm just at a lost. Any Ideas how i can get this setup with the predefined quantities that also updates weight for shipping?
I'm using magento 1.6.0
Well after some more searching I found something that works....
http://www.magentocommerce.com/boards/viewthread/73036/

Categories