Function to verify if product has stock enough in magento - function

Is there a way to create a function to verify if the product has stock enough before the client add the product to the cart? Thanks in advance.

Related

How to change the stock reservation in Magento from pending to processing?

How can I prevent Magento from reserving product stock on "pending" orders. Generally allow stock quantity reservation for paid orders only.
Thanks a lot!
This can't be done without code changes.
In Order to generally prevent Magento from subtracting stock quantity from products you may use system configuration field "Decrease Stock When Order is Placed" set to "no" under System Config->Catalog->Inventory
To achieve desired behaviour you may try following Solution:
Disable default magento behaviour by setting "Decrease Stock..." to
"no"
Create new local Module
Add Observer for event sales_order_save_after
Compare status values and decrease stock when needed

Magento reindexing a particular single product -Magento 1.9

My magento store has products around 30000. Everytime i upload/update new product, i have to reindex the whole store which takes very huge time. So basically i would like to have a php script or any method which reindex all the indexes of a particular single product. Is there any defined script/method to achieve?? please help, thank you in advance

Magento : one customer give only one review to product

I have product's review on product page now. But logged-in customer gives review more then once. I need only one review from one customer, not more than that.
Can you please suggest??
Thanks in Advance.

Magento MySQL database stock update

I need some help updating all configurable products from
Manage Stock = no
and
Stock Availability = no
to
Manage Stock = yes
and
Stock Availability = yes
via the database...
the stock for the products I believe is in the table
cataloginventory_stock_item
however I can't see where the product type = configurable is defined in this table, which causes a bit of an issue as I can't see which to update...
Any thoughts would be very appreciated
Regards
Henry
if you only update the configurable product quantity,best solution is Go to admin>system>Import/Export>Dataflow - Profiles>Export Product Stocks
Then select only Mapped Fields in Data Format and add these required fields (screen shot below) in Field Mapping section and save and continue,
Then go to Run Profile section in your left hand side and click on Run Profile button.
Connect FTP or download your csv root/var/export/export_product_stocks.csv update product inventory or import Import/Export>Dataflow - Profiles>import Product Stocks
upload your file and same run profile.
your all product's inventory will be updated.
Thanks......

Licence to use website and products database schema help

I'm building a website and I'll be charging my customers to use it. I'm thinking of having 6 monthly or yearly licence options and there'll be a few different variations of licences available each granting different types of access to the site.
Also I'll have a few optional extras that you can add on to the purchase of their licence. These would be once-off purchases more like products rather than licences. They're more add-ons for the website that enable more features. Once purchased you get to keep it. So everything's based on the site there's no shipping to worry about.
This will be displayed in some sort of shopping cart fashion where they can choose what they want then sent through to Paypal for processing.
Just wondering how I would model this correctly in my database? So far I've come up with:
Database schema
Basically I've tried to put licences and products in the same table and used a flag column (licence_or_product) to distinguish between the two. This would help in the display on the website about whether it's a product or licence.
Is it worth having the licence *offering_start_date* and *offering_end_date* fields? I'm trying to get it so that I can expire that offering if I want to make a new licence offering with a different price. That way customers who have already purchased the licence at that price it always stays at that price. If I want to change the price, I'll set the offering end date to today, then make a new licence_products row with a lower price but end_date in the future. Is that the right way to do it? Or do you just edit the price of the item directly? I'm just thinking if the price changes then the customer wants a refund for that licence, how do you track how much they paid for that licence? The amount_paid field would tell me how much the whole order cost but not the original price of the licence which has now changed. Do I need a history of all the product price changes?
Other thing I don't know how to do, lets say they've purchased a licence to use the site for a year. How do I pull out which is the most current licence? Lets say I've started them off with a 30day trial licence, then they purchase a yearly licence. Do I invalidate the trial licence immediately? I think I only want one valid licence at a time. So if they buy another licence before the old one expires I'm not sure how my program should handle that.
Any help much appreciated. Thank-you!
P.S. Here's the SQLyog database schema and SQL if you want to have a go at reworking it a little.
sql db extract
SQLyog schema
I think you should create the following 3 tables:
1. customer (client or whatever make sense to you),
2. license and
3. customer_license.
And I suggest the following fields for the customer_license table:
id (some int auto_increment)
customer_id (some int) FK
license_id (some int) FK
price_offered decimal(7,2) (with the precision you need)
expiration_date date
active tinyint(1)
created_at datetime
updated_at datetime
This way you can track all details of the customer with the license you offered them: what you offered? when you offered? when does it expire? price offered? the license is active?
Good luck