How can I flush the Magento cache programmatically
You can use cleanCache method to clear Magento cache
Mage::app()->cleanCache()
or
Mage::app()->getCacheInstance()->flush();
How can I flush the Magento cache programmatically
You can use cleanCache method to clear Magento cache
Mage::app()->cleanCache()
or
Mage::app()->getCacheInstance()->flush();
How can I create or auto generate Magento coupon codes programmatically.
First, you need to create a sales rule or load an existing sales rule and then use “salesrule/coupon_massgenerator” model to create the coupons.
$generator = Mage::getModel('salesrule/coupon_massgenerator'); $data = array( 'max_probability' => .25, 'max_attempts' => 10, 'uses_per_customer' => 1, 'uses_per_coupon' => 1, 'qty' => 2, //number of coupons to generate 'length' => 10, //length of coupon string 'to_date' => '2017-9-11', //ending date of generated promo 'format' => Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC, 'rule_id' => 1//the id of the rule you will use as a template ); $generator->validateData($data); $generator->setData($data); $generator->generatePool();
How can I reindex a Magento index programmatically, like what I did via command line – php indexer.php –reindex catalog_product_price
You need to use model – “index/process” and load the index by ID, then call “reindexAll” function
$process = Mage::getModel('index/process')->load(2); // 1 - catalog_product_attribute // 2 - catalog_product_price // 3 - catalog_url // 4 - catalog_product_flat // 5 - catalog_category_flat // 6 - catalog_category_product // 7 - catalogsearch_stock // 8 - cataloginventory_stock // 9 - tag_summary $process->reindexAll();
How can I add a Magento product to current cart programmatically
You need to use checkout/cart and catalog/product models to add Magento product to the current cart
$cart = Mage::getSingleton('checkout/cart'); $cart->init(); $options = array('1'=>'3','2'=>'6'); // product options $product = Mage::getModel('catalog/product')->load(2); // product id - 2 $paramater = array('product' => '2', // product id - 2 'qty' => '1', 'form_key' => Mage::getSingleton('core/session')->getFormKey(), 'options' => $options ); $request = new Varien_Object(); $request->setData($paramater); $cart->addProduct($product, $request); $cart->save();
I have 2 Magento stores, store A, store B.When I add product to the store A cart, I can see it from store B cart. What can I do if I add a product from store A, should not see it from store B cart
You can set different cookie domain for each Magento store.
I have a Magento with 2 stores, I would like export store 2’s product from database, which database table should I look
Usually for store 2, you should have a table catalog_product_flat_2 which is including most product details
How can I set canonical url for magento cms page manually from Magento backend
You can set canonical url from design tab of CMS page.
* add/edit a CMS page
* click design tab
* then add follow codes to the field of Layout Update XML
<reference name=”head”> <action method=”addLinkRel”> <rel>canonical</rel> <href>http://softwarehtec.com/</href> </action> </reference>
Currently, I am building my own extension, I would like to know how to add Magento bundle product to current cart programmatically
The following is example of how to add a Magento bundle product to current cart programmatically
$params = array( 'product' => 1, 'related_product' => null, 'bundle_option' => array( // your bundle option 2=> 4, 2=> array( 0 => 5, ), 13 => array( 0 => 8, 1 => 9, ), ), 'options' => array( // your custom option 2 => 'Test', ), 'qty' => 2, ); $cart = Mage::getSingleton('checkout/cart'); $product = new Mage_Catalog_Model_Product(); $product->load(1); $cart->addProduct($product, $params); $cart->save(); Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
I would like to include some extra jQuery addon files to my Magento cms page. How to do it
1. You have to add your extra jQuery add-on library to your head.phtml file from your active theme.
2. Execute the extra jQuery add-on function from the footer.phtml of your active theme.
After installed my new Magento, I have got error like failed to open stream : No such file or directory
Warning: include_once(Mage/Core/functions.php): failed to open stream: No such file or directory in /public_html/app/Mage.php on line 49
Warning: include_once(): Failed opening ‘Mage/Core/functions.php’ for inclusion (include_path=’/public_html/app/code/local:/public_html/app/code/community:/public_html/app/code/core:/public_html/lib:.:/usr/lib/php:/usr/local/lib/php’) in /public_html/app/Mage.php on line 49
Warning: include(Mage/Core/Model/App.php): failed to open stream: No such file or directory in /public_html/lib/Varien/Autoload.php on line 94
Warning: include(Mage/Core/Model/App.php): failed to open stream: No such file or directory in /public_html/lib/Varien/Autoload.php on line 94
Warning: include(): Failed opening ‘Mage/Core/Model/App.php’ for inclusion (include_path=’/public_html/app/code/local:/public_html/app/code/community:/public_html/app/code/core:/home/hoytoynl/public_html/lib:.:/usr/lib/php:/usr/local/lib/php’) in /public_html/lib/Varien/Autoload.php on line 94
Fatal error: Class ‘Mage_Core_Model_App’ not found in /public_html/app/Mage.php on line 66
To solve this Magento error,
1. double check those files exist on your server
2. clear cache
3. check those files’ permission is readable