External Blog
  • Blog
  • About
  • Contact

2/20/2018

Magento Coding Procedures

2 Comments

Read Now
 
Picture
Download Extension Manually Using Mage:
Use a manual download process to work with Magento and use certain values you conceive through a selective process completing the coding in form of a snippet in Magento. 
Proceed in your coding process with re-indexing and confirm use of various attributes you want to have when you are beginning the development process.
./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
Reindex:
php -f shell/indexer.php reindexall
<?php
// clear cache
Mage::app()->removeCache('catalog_rules_dirty');
// reindex prices
Mage::getModel('index/process')->load(2)->reindexEverything();
/*
1 = Product Attributes
2 = Product Attributes
3 = Catalog URL Rewrites
4 = Product Flat Data
5 = Category Flat Data
6 = Category Products
7 = Catalog Search Index
8 = Tag Aggregation Data
9 = Stock Status
*/
Delete cache/sessions
rm -rf var/log/*
rm -rf var/cache/*
rm -rf var/session/*
rm -rf var/report/*
rm -rf var/locks/*
rm -rf app/code/core/Zend/Cache
rm -rf var/ait_rewrite/*
rm -rf media/css/*
rm -rf media/js/*
// if there are many files which can't get deleted in once
find /path/to/session/* -mtime +1 -exec rm {} \;
Magento Code Snippet Methods
Load category by id:
Loading the category of id as well as loading of product by id or sku makes the category and product definition come into action where there is necessary editing required. Make loading of category in increasing order that makes you have all entries come into process and work with arrangement of variables used in the code snippet.
<?php
$_category = Mage::getModel('catalog/category')->load(89);
$_category_url = $_category->getUrl();
Load product by id or sku
<?php
$_product_1 = Mage::getModel('catalog/product')->load(12);
$_product_2 = Mage::getModel('catalog/product')->loadByAttribute('sku','cordoba-classic-6-String-guitar');
Get Configurable product's Child products
<?php
// input is $_product and result is iterating child products
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
Get Configurable product's Children's (simple product) custom attributes
<?php
// input is $_product and result is iterating child products
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($_product);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
foreach($col as $simple_product){
            var_dump($simple_product->getId());
}
Log to custom file:
<?php Mage::log('Your Log Message', Zend_Log::INFO, 'your_log_file.log'); ?>
Call Static Block
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block-name')->toHtml(); ?>
Add JavaScript to page:
First approach: page.xml - you can also add something like:
<action method="addJs"><script>path/to/my/file.js</script></action>
Second approach: Find page/html/head.phtml in your theme and add code directly to page.html.
Third approach: If you look at stock page.html mentioned above, you will notice the following line:
<?php echo $this->getChildHtml(); ?>
Normally, the getChildHtml method ends up in a specific child block. However, if called without paramater, getChildHtml will automatically turn all child blocks. That means you can add something like:
<!-- existing line --> <block type="page/html_head" name="head" as="head">
                <!-- new sub-block you're adding --> <block type="core/template" name="mytemplate" as="mytemplate" template="page/mytemplate.phtml"/>
                ...
These are extra web pages like page.xml, and make an addition to the mytemplate.phtml file as well. Any block inclusive to a head block automatically appears. (This programmed rendering does not apply to every layout block only use of blocks where getChildHtml adds is without parameters).
Get to the current category/product/cms page and make your products you want to sell known making initiation of web based buying.
<?php
$currentCategory = Mage::registry('current_category');
$currentProduct = Mage::registry('current_product');
$currentCmsPage = Mage::registry('cms_page');
Coding through Magento Platform
Run Magento Code Externally:
Use the snippets and run them externally to complete the execution process and check whether there are positive results you want with Magento coding. The PHP coding is what shows the difference that you can use to make external execution of coding in Magento run according to expectation. The snippet changes the demonotice configuration from 0 to 1 and vice versa with the default value being 0.
<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();
// Run you code here
Programmatically change Magento’s core config data
<?php
// find 'path' in table 'core_config_data' e.g. 'design/head/demonotice'
$my_change_config = new Mage_Core_Model_Config();
// turns notice on
$my_change_config->saveConfig('design/head/demonotice', "1", 'default', 0);
// turns notice off
$my_change_config->saveConfig('design/head/demonotice', "0", 'default', 0);
Changing the Admin URL:
Open up the /app/etc/local.xml file, locating the <frontName> tag, and alter the ‘admin’ part to something a lot more dispersed, eg:
<frontName><![CDATA[supersecret-admin-name]]></frontName>
Clear your cache and session:
Magento: Mass Exclude/Unexclude Images:
By default, Magento sees an 'Exclude' box for you on imported images, making them not show up as a thumbnail labelled below the main product image on your product view.
# Mass Unexclude
UPDATE`catalog_product_entity_media_gallery_value` SET `disabled` = '0' WHERE `disabled` = '1';
# Mass Exclude
UPDATE`catalog_product_entity_media_gallery_value` SET `disabled` = '1' WHERE `disabled` = '0';
getBaseUrl – Magento URL Path
<?php
// http://example.com/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
// http://example.com/js/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
// http://example.com/index.php/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
// http://example.com/media/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
// http://example.com/skin/
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
Get The Root Category In Magento
<?php
$rootCategoryId = Mage::app()->getStore()->getRootCategoryId();
$_category = Mage::getModel('catalog/category')->load($rootCategoryId);
// You can then get all of the top level categories using:
$_subcategories = $_category->getChildrenCategories();

Share

2 Comments
downloadhappychickapk.com link
12/25/2018 09:47:27 pm

Can I just say what a relief to find someone who actually knows what they’re talking about on the internet? You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I can’t believe you’re not more popular because you definitely have the gift.

Reply
run 3 link
3/27/2020 12:35:17 pm

Obviously, the office of instructing of the objective dialect is given by the local speaker or the general population who are great in the objective dialect. Their involvement in that dialect is high. This office is additionally given by the objective nations.

Reply



Leave a Reply.

Details
Site powered by Weebly. Managed by Webspawner by Sibername.com
  • Blog
  • About
  • Contact