Updating WooCommerce products by php - php

I have an e-commerce store made with WooCommerce. In my store I have implemented a plugin, which allow users to subscribe to prices of specific products. This plugin informs the user only about a price change via email, when I manually change the price and save the product. This works perfect.
So far so good, the only problem is that I don´t change the prices manually, because they´re generated automatically by another plugin.
My goal is now to just save every product of my store every hour by a php-script and a cronjob. How to set up a cronjob is not the problem, but I don´t know the php-script.
All in all the php-script only has to be able to go into every product and just save it.
Because I´m new to WordPress and PHP, I don´t have any clue.
Thank you very much for helping out!

Related

Send orders from OpenCart to WooCommerce

I am having very specific task that needs to be implemented. I have to import specific orders from one OpenCart shop to another WooCommerce shop. The reason we're doing this is because in the woocommerce shop there are some functionalities that we don't want to implement on the OC and we just want to use the WooCommerce.
One of the options i thought about was to get the orders from the database directly / they are using the same server so that's easy to access /, but I run into an issue trying to pass the Shipping method ( because it comes from the checkout and shows a form in the backend that we need ).
So I am thinking of another way to simulate the process through the WooCommerce REST API, but I am not sure from where to start.. Have someone worked on similar thing, I would appreciate if I get some guidance.
Thanks in advance!!

Creating a woocommerce store that gets products from another website

I am in need of guidance:
I need to create a woocommerce store that will get its products from another website like this one. Is it possible to make it to auto update? For example, every time a product is introduced into the first store, the same product will appear in my woocommerce store?
Thanks for your time!
You can try using file_get_contents() to read the other website then you can parse the pages you receive to select the products and display your own page on the fly.

Magento cron job export / import products

My client has an existing Magento store online. Now, they wanna to setup another store at different region. Of course, they will have different currency, shipping method, payment method, different price and different inventory stock check.
Therefore, they required to replicate the same existing store to another folder. Now my problem is they want to have same product range available from both website. My product list is comprised of simple and configurable products only.
I need to set a cron job to export product lists in csv from website A.
And I need to set another cron job to fetch that csv file from website A to website B. However, the product list to be imported into website B should not
duplicate same record
update inventory and price value
My current setup for both website are hosted in same server.
I not sure how this can be done. Anyone can guide me. Thanks.
why do u want to set-up whole new magento store for second region.
u can use magento's multiple store. for that u don't have to import and export of product. infact u just have to create new magento store and payment methods, currency or whatever u want to change u can change those from configuration very easily, u can use differnt theme for both differnt stores also.
U can use this link as a refrence
http://www.crucialwebhost.com/kb/how-to-setup-multiple-magento-stores/

Get notified on stock unavailability

I am trying to create a "Notify me" feature if the stock is unavailable.
On search on admin panel, I could find only that a user should sign up / log in to get notified about the stock availability.
But I just want to let the user (a guest) enter only his/her email address to get notified.
How should I do this?
Please give suggestions..
EDIT:
I have got this link, which gives me a way to start.
Till now what I did is added the following code in my template file which is creating a url for redirect (thinking to do it in ajax way, to stop page refreshing).
<?php
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$base64 = strtr(base64_encode($actual_link), '+/=', '-_,');
$postUrl = "http://$_SERVER[HTTP_HOST]/efk/productalert/add/stock/product_id/" . $simpleProduct->getId() . "/uenc/". $base64;
?>
In the above code, efk is my project folder name.
After this, I have gone to productalert/add/stock controller method i.e stockAction() which is calling sign up / login form (I think so) using $model->save();.
How should I disable this save calling and add my own small overlay which holds a textbox to enter a email address?
Magento has "Notify me when product is back in stock" feature out of the box. It can be configured in admin panel: system / configuration / catalog / product alerts and product alerts run settings.
You're right, it works only for registred customers. To make it working for guest users some coding is required. I'd say you need to do the following steps:
Add email column to product_alert_stock table
Create new controller and action (believe me, it's better than you override existing one via config.xml) which extends Mage_ProductAlert_AddController::stockAction(). Your method will have to set guest's email to productalert/stock model.
Create subscription form and make sure it submits data to your new controller/action.
Update (override) Mage_ProductAlert_Model_Observer::_processStock() method to make it respect situations when "customer" has no ID but has email.
When you'll be testing, I suggest you to install SMTP Pro Email extension and mailcatcher to ease the testing process.
We have done this (http://www.alfresia.co.uk/sorrento-side-table.html/). Here we ended up creating a custom module as when we did this magento did not support any product alert system for the guest users (i do not know if this is supported now).
We first created a text box which would appear on product page where the product is out of stock. We were saving this info in one of our custom tables where we the schema was {id, email, product_sku, status} (status had three values Awaiting Stock, In Stock, and Already Notified).
We then wrote an observer which was hooked to cataloginventory_stock_item_save_after event, this helped us get the product sku which has been back in stock, and update all entries in our custom table with status In Stock and send a mail to the user.
This is how we did it, surely there will be a much cleaner way doing this.
You could have work with plugins. MagentoCommerce has loads of plugins/extensions which does the same
Free Version - http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html
I too had similar requirement, and have installed 'http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html' this plugin.
Well this plugin does the job, But they have override complete product view page template instead of simply adding a new block. By this your custom development on product view page development might get reflected on frontend.
Or else this plugin definitely does the job.
This http://www.magentocommerce.com/magento-connect/product-out-of-stock-subscription-1350.html plugin is really good but it breaks for configurable product types and it completely overrides the product controller which makes your system vulnerable to future upgrades. I think observers should be hooked to events where the product is back in stock and should update the users.

Magento - Programatically added bundle product isn't available for the basket/frontend

I followed this answer which works fine: Magento - Programatically added bundle product isn't showing up in frontend
I'm able to generate a bundle product on the fly. Everything works fine.
Only one problem: My bundle product is correctly saved and I can see it through the admin area. But, after this generation on the fly, I have to add directly this product into the basket. The system returns "product not found". Basically, I have to go into the admin area, just save it and then I'm able to add it to the basket.
I really suspect a problem with the indexer but I can't really figure out what's going on.
I tried many solutions like:
Mage::getSingleton('index/indexer')->processEntityAction(
$product,
Mage_Catalog_Model_Product::ENTITY,
Mage_Index_Model_Event::TYPE_SAVE
);
But it still doesn't work.
Any Idea about which code I should trigger after the save method to index only this new added bundle product.
Thank you in advance.
Sounds like you are not creating a stock-item with your product. Therefore there is no stock and you can't add it to your basket?
Have a look into
/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php:672
/app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php:571
where a product is generated and the stock data are cleand up / set with default data

Categories