Skip to content

Category: PHP

Magento 2 : Admin Ajax Upload File

Here’s steps how to create custom ajax upload file in admin page create controller file 2. in your custom phtml file

Comments closed

M2 : Override/Intercept REST API POST params

ok then in your di.xml <?xml version=”1.0″ ?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”> <type name=”Magento\Webapi\Controller\Rest\Router”> <plugin disabled=”false” name=”YourModule_ModuleName_Plugin_Magento_Webapi_Controller_Rest_Router” sortOrder=”10″ type=”YourModule\ModuleName\Plugin\Magento\Webapi\Controller\Rest\Router”/> </type> </config> and then finally, use plugin …

Comments closed

Magento2 : Custom Sql Directive

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); // Instance of object manager $resource = $objectManager->get(‘Magento\Framework\App\ResourceConnection’); $connection = $resource->getConnection(); $tableName = $resource->getTableName(‘your_table_name’); //Select Data from table $sql = “Select *…

Comments closed

[Magento]Delete Log Files Programatically

$dir = Mage::getBaseDir(‘var’) ; unlink($dir.’/log/exception.log’); unlink($dir.’/log/system.log’); be careful, you can also delete other files :p

Comments closed

[Magento] Update category attributes programmatically

here you go $resource = Mage::getResourceModel(‘catalog/category’); $collection = Mage::getModel(‘catalog/category’)->getCollection(); foreach($collection as $category) { $category->setStoreId(0); // 0 for default scope (All Store Views) $category->setData(‘page_layout’, ‘two_columns_left’); $resource->saveAttribute($category,…

Comments closed

Magento 2 : Create Admin User From Shell

use SSH to perform this action, from your Magento root, use this command   php bin/magento admin:user:create –admin-firstname=”Admin Fistname” –admin-lastname=”Admin Lastname” –admin-user=”admin_username” –admin-password=”admin_pass” –admin-email=”[email protected]”  

Comments closed

Magento 2 : Add Customer Address Attribute

in your ‘Company/Modulename/setup/InstallData.php’ here example code <?php namespace Company\Modulename\Setup; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Customer\Model\Customer; use Magento\Customer\Setup\CustomerSetupFactory; class InstallData implements InstallDataInterface { private…

Comments closed

Magento : Create Fake POST

$array_post = array( ‘var1’=>’content1’, ‘var2’=>’content2’, ); $array_post = http_build_query($array_post); $opts = array(‘http’ => array( ‘method’ => ‘POST’, ‘header’ => ‘Content-type: application/x-www-form-urlencoded’, ‘content’ => $array_post )…

Comments closed

Magento : Custom Email Template on Custom Module

here the XML guide <template> <email> <{section_name}_{group_name}_{fields_name} translate=”label” module=”mymodule”> <label>Custom Email Template</label> <file>mymodule/custom_email.html</file> <type>html</type> </{section_name}_{group_name}_{fields_name}> </email> </template>   <{fields_name} translate=”label”> <label>Email Template</label> <frontend_type>select</frontend_type> <source_model>adminhtml/system_config_source_email_template</source_model> <sort_order>5</sort_order>…

Leave a Comment

Magento : Manggil data produk ngangge SKU

sederhana sih, ngan sok poho wae…jadi mending di catet weh,   mangga   $product = Mage::getModel(‘catalog/product’); print_r($product->load($product->getIdBySku(‘SKU_DI_DIEU’))->getData());

Leave a Comment

Magento : Munculkeun Daftar Nilai Attribute ti Spesifik Attribute

jaga2 bisi poho..soalna sering dipake,….ieu carana keur munculkeun attribute value, mangga ah..haha   $name=’size’;  /*kode attribute na di dieu*/ $attributeInfo = Mage::getResourceModel(‘eav/entity_attribute_collection’)->setCodeFilter($name)->getFirstItem(); $attributeId = $attributeInfo->getAttributeId();…

Leave a Comment

Magento : Fix Fatal error Call to a member function getName() on a non-object in ImportExport/Model/Export/Entity/Product.php on line 172

this is a dirty way to fix this issue, go to Fatal error: Call to a member function getName() on a non-object in app/code/core/Mage/ImportExport/Model/Export/Entity/Product.php on line…

Leave a Comment