Skip to content

Instantly share code, notes, and snippets.

View mukundthanki's full-sized avatar

Mukund Thanki mukundthanki

View GitHub Profile
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
@mukundthanki
mukundthanki / jet_php_api_template.php
Last active December 26, 2015 12:03 — forked from dsugarman/jet_php_api_template.php
Jet PHP API Template
<?php
/** To use this just:
1. put in your api information at the top
2. store/retreive your API token in the specified locations
3.store your api calls
Ex: $jet->uploadFile($feed_type, $path);
$jet->processOrdersByStatus('ready');
$jet->apiPUT("/orders/".$JET_ORDER_ID."/acknowledge", $data);
**/
<div id="wanelo-button">
<a class="wanelo-save-button"
href="<?php echo $home_url; ?>"
data-url="<?php echo $this->helper('core/url')->getCurrentUrl();?>"
data-title="<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?>"
data-image="<?php echo $_product->getImageUrl(); ?>"
data-price="<?php echo number_format($_product->getFinalPrice(),2);?>"></a>
<script async="true" type="text/javascript" src="//cdn-saveit.wanelo.com/bookmarklet/3/save.js></script>
</div>

Magento Snippets

Simulate and test AJAX fail() actions in Mangeto

<?php
public function testAction()
{
        $this->getResponse()
            ->setHeader('HTTP/1.1', '403 Session Expired')
            ->setHeader('Login-Required', 'true')
<?php
/**
* Debugging WordPress things.
*
* All of this belongs in your wp-config.php file.
*
* This will make sure that the code you release is, at a minimum,
* relatively free of PHP notices and warnings.
*
* - WP_DEBUG: This turns on debugging mode.
@mukundthanki
mukundthanki / delete_all_products.sql
Last active December 31, 2015 14:29
Delete all products using sql queries in magento
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;
TRUNCATE TABLE `catalog_product_entity_text`;
@mukundthanki
mukundthanki / advanced-data-profile.md
Last active December 28, 2015 23:28
Import/Export Data using Adavanced data profile in magento.

Export All Products

Output as csv

<action type="catalog/convert_adapter_product" method="load">
    <var name="store"><![CDATA[0]]></var>
</action>
<action type="catalog/convert_parser_product" method="unparse">
    <var name="store"><![CDATA[0]]></var>
 <var name="url_field"></var>
# one-liner for generating this: mysqldump --no-data -uroot magento1600 | nawk '{if(match($0, /CREATE TABLE `(.*)`/, matchesT)) { the_table = matchesT[1]; } if(match($0, /(CONSTRAINT .*),?/, matchesK) && the_table) { the_key = gensub(/,?$/, "", matchesK[1]); the_key = gensub(/^ */, "", the_key); print "ALTER TABLE `" the_table "` ADD", the_key ";"; }}'
ALTER TABLE `admin_rule` ADD CONSTRAINT `FK_ADMIN_RULE_ROLE_ID_ADMIN_ROLE_ROLE_ID` FOREIGN KEY (`role_id`) REFERENCES `admin_role` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `api_rule` ADD CONSTRAINT `FK_API_RULE_ROLE_ID_API_ROLE_ROLE_ID` FOREIGN KEY (`role_id`) REFERENCES `api_role` (`role_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `api_session` ADD CONSTRAINT `FK_API_SESSION_USER_ID_API_USER_USER_ID` FOREIGN KEY (`user_id`) REFERENCES `api_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `catalog_category_entity_datetime` ADD CONSTRAINT `FK_CAT_CTGR_ENTT_DTIME_ATTR_ID_EAV_ATTR_ATTR_ID` FOREIGN KEY (`attribute_id
@mukundthanki
mukundthanki / install-magento-using-terminal
Last active December 24, 2015 01:29 — forked from tonyoconnell/gist:2351492
Install Magento 1.8.1.0 with sample data via ssh
mkdir mage_test
cd mage_test
wget http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz
wget http://www.magentocommerce.com/downloads/assets/1.6.1.0/magento-sample-data-1.6.1.0.tar.gz
tar -zxvf magento-1.8.1.0.tar.gz
tar -zxvf magento-sample-data-1.6.1.0.tar.gz
mv magento-sample-data-1.6.1.0/media/* magento/media/
mv magento-sample-data-1.6.1.0/magento_sample_data_for_1.6.1.0.sql magento/data.sql
mv magento/* magento/.htaccess .
chmod o+w var var/.htaccess app/etc
@mukundthanki
mukundthanki / functions.php
Last active March 26, 2018 06:27
WordPress: Insert multiple files and attach them to post from front-end.
<?php
# Upload multiple files and attach them to post using single function
// Files Uploader attach to shop
if ($_FILES) {
$files = $_FILES['shop-imgs'];
foreach ($files['name'] as $key => $value) {
if ($files['name'][$key]) {
$file = array(
'name' => $files['name'][$key],