Search results for: 'test'
Results in Category pages.
-
Magento
All premium extension for magento are listed here. You can also find appropriate free magento plugins and magento themes here like schedule order email notfication after place order . Magento CMS & Aw Blog Integrated search , Magento Portfolio , Magento Testimonial , Ultimate slider ,
-
CMS Services
Content management system (CMS) in context of websites is indicate to the system that allows personnel of a company to manage their website content on their own. We at Samdoit offer open source CMS services to fulfill your latest demands and trends of e-business. Our motive is not only to develop, deploy and maintain content of rich websites effectively but also to reduce the cost of website maintenance.
Wordpress
Now a day Wordpress has globally become a well known powerful CMS platform to publish different blogs on a website. Wordpress is an open source Content Management System which helps to update, manage and edit the content of website as well. Wordpress is an excellent CMS and most powerful tool for publishing blog on website. Samdoit offer effective and cost affordable Wordpress Development and customization services for customers. We also provide Wordpress migration service that can help you to convert any HTML, Joomla website into Wordpress website.
Joomla
Joomla is one of the most used Open Source Content Management System (CMS). Joomla helps to build content rich dynamic web portals and website applications. Joomla is the most powerful CMS in internet world. Joomla is a free open source content publishing system for creating highly interactive multi language websites, eCommerce Applications, Real Estate Portals, media portals, online communities, etc...
Drupal
We develop web sites using the Drupal content management system (CMS). Drupal is open-source software with user friendly functionalities such as search, access control, user login, hacker prevention capabilities and more. On top of Drupal, we can install and configure additional modules to add additional functionalities to the website. These can be event calendar, blog, email newsletters, social networking features, etc. The main advantages of Drupal CMS are that lets you check some boxes to turn your website into a full-blown website.
Open source CMS customization
- Ecommerce stores and Auction Website
- Blogs and Forums
- Online Classifieds and job portals
- Document and Event Management Systems
- Multi Language Websites
- Online Shopping cart websites
- Social Networking Websites
Results in Magefan Blog.
-
How To Add Banner Ads To Ionic Apps Using AdMob Pro Plugin
In this post I will show how you can add banner ads to your Ionic apps. I will be doing this on a new app but you can do it to your existing app as well. I have also written a post on adding banner ads to Ionic 2 apps, so if you are looking for Ionic 2 apps You can check that post out as well.
Step 1)
We will first start by creating a new Ionic project by issuing the following command in the command prompt
1ionic start MyNewApp TabsStep 2)
Now we will need to add the platform to out app. So will do the following command
Step 3)
As we will be using the AdMob Pro plugin we will need to download it in our project. We will do that by the following command
you can read more about the plugin in the Admob pro plugin documentation
Step 4)
Now we will need to add the following code to the $ionicPlatform.ready() in the app.js file
So the finished app.js file looks like this:
NOTE: The app.js file will be different for each template namely tabs,bank,sideMenu, make sure you add the code to the $ionicPlatform.ready() function and no to any function inside it.
-
Magento Module Development Database Option
In this blog we will see advanced operations in model and collection, to execute complex sql queries. We will look into collections and details of resource models.First let’s look at model and collection architecture in magento. If you look at a magento model class it extends Mage_Core_Model_Abstract which intern extends Varien_Object.The class Mage_Core_Model_Abstract has function like getId(), load(), save(), delete() etc .
SQL and Mysql4 Resource FilesMysql4 resource files, as I mentioned earlier are used to perform database queries on tables. Below will list how we do sql operations inside resource files.
SELECT QUERY
Suppose we have the file Excellence_Test_Model_Mysql4_Test resource file.
<?php class Excellence_Test_Model_Mysql4_Test extends Mage_Core_Model_Mysql4_Abstract { public function _construct() { $this->_init('test/test', 'test_id'); } public function loadByField($field,$value){ $table = $this->getMainTable(); $where = $this->_getReadAdapter()->quoteInto("$field = ?", $value); $select = $this->_getReadAdapter()->select()->from($table,array('test_id'))->where($where); $id = $this->_getReadAdapter()->fetchOne($sql); return $id; } }And here is the model file Excellence_Test_Model_Test
<?php class Excellence_Test_Model_Test extends Mage_Core_Model_Abstract { public function _construct() { parent::_construct(); $this->_init('test/test'); } public function loadByField($field,$value){ $id = $this->getResource()->loadByField($field,$value); $this->load($id); } }In this file there are many new functions which have been used. Let’s take them one by one.
In our model file, we have used this function
$id = $this->getResource()->loadByField($field,$value);
$this->getResource() function returns the resource model’s object. So we are simply calling the loadyByField($field,$value) function in the resource model.
getTable() function
Now in our Mysql4 file, in the loadByField() function we have used $table = $this->getMainTable(); .This function returns the table name of the current model, i.e the one defined in the class’s constructor. If you want to get table name of another sql table in magento, we need to the getTable() call e.g
$table = $this->getTable(‘newsletter/subscribe’);
_getReadAdapter() function
Next we have: $where = $this->_getReadAdapter()->quoteInto(“$field = ?”, $value);
Here the first function too see is the $this->_getReadAdapter() function. This function return an object which has function to perform database query, like fetch(), fetchAll(), query(), etc.
Next, in read adapter, we can perform operations like:
- fetchAll() : returns entire database table in multiple dimensional array as per the select query. e.g if we are executing an sql like “select * from table_name”, we would use the fetchAll() function to get all the values.
- fetchRow(): returns a single row of the database table as per the select query. e.g if we are executing sql like “select * from table where id = ’1′” would use fetchRow() to get the single row.
- fetchCol(): returns single column of a database table as per the select query. e.g if query is a select name from table” we would use fetchCol() function.
- fetchOne(): return since value, i.e single row and single column. e.g if sql query “select count(*) from table” then we would use fetchOne()
The read adapter has many other functions as well, but above are the important functions used.
_quoteInfo() function
Another function we have used is quoteInto(): This function is used to create our where conditions. In this the actual value is substituted into the question mark we have written. For e.g $this->_getReadAdapter()->quoteInto(“user_id = ?”, 3); translates to
“user_id = 3″. Another frequently used variation of quoteInfo() is
$where = $this->_getReadAdapter()->quoteInto("$field IN(?)", array(1,2,3));this translates to “field in (1,2,3)”
Getting deeper into the quoteInto() function: If we have multiple where conditions we can use
$where = $this->_getReadAdapter()->quoteInto("$field = ? AND ", $value).$this->_getReadAdapter()->quoteInto("$field1 = ? OR ", $value1).$this->_getReadAdapter()->quoteInto("$field2 = ?", $value2);So this way, we can have multiple where conditions.
Continuing on the loadByField function in our resource model, next we have
$select = $this->_getReadAdapter()->select()->from($table,array(‘test_id’))->where($where);
Here we have created the select query using the select(), and on that called the from() function.
from() function
The from() function takes many different parameters, if you want to fire a simple select * query, you need to only pass the table name like from($table).
But right now, I wanted to select just a single column that is test_id, so I passed an array with column name to select. i.e array(‘test_id’). If we want to select multiple column, we need to array(‘test_id’,’col1’,’col2’). This will create a sql like
“select test_id,col1,col2 from $table”. But support we want a sql query like
“select test_id as id,col1 as column1 from $table” , i would call
from($table,array('id'=>'test_id','column1'=>'col1'));Note:
If you want to see the exact sql that is generated by your function, you can any time do this
<?php echo $select; ?>
Again, back to the loadByField() function. The last line
<?php $id = $this->_getReadAdapter()->fetchOne($sql); ?>
This is already explained, above.
Select ObjectThe select() function we used above return a select object which provides us with many more functions to perform all operations on a sql query. The class for the select object is Varien_Db_Select, where you can look into more details for all functions. Let look at a sample php code below.
public function getAll(){ $table = $this->getMainTable(); $where = $this->_getReadAdapter()->quoteInto("id = ?", 123); $select = $this->_getReadAdapter()->select()->from($table)->columns(array('test_id'))->where($where)->limit(10,5)->order('created_time')->group('list_id')->having('list_id > ?',10); echo $select; }As we can see all function in the select object, return the select object itself. Due to this we are able to chain the functions.
In this example, I have used almost all the sql select parameters you might require expect joins, which will be covered later.
Let’s take each function one at a time.
- select() : used to initialize the sql query. This returns the Select object, which is the object on which we do all our operations.
- from(): table name on which select operation is done. we have seen this in detail above.
- columns() : here we can specify exactly which columns to select in the query
- where() : used to give the where condition
- limit(): takes to parameters. First are how many rows to return and second is offset from where to start. So in current case, it means return 10rows, leaving first 5rows.this uses the LIMIT 10 OFFSET 5 syntax in sql query, rather than LIMIT 10,5
- order(): you can set how you want to order the result set. Default is ascending order. But if you want to mentioned descending order you do order(array(‘created_time Zend_Db_Select::SQL_DESC))
- group(): put group by clause in your select query in the specified field.Having(): put having condition for group by clause.
JOINS
Let look at sample function.
public function joinUs() { $table = $this->getMainTable(); $table2 = $this->getTable('customer/entity'); $cond = $this->_getReadAdapter()->quoteInto('t1.id = t2.customer_id',''); $where = $this->_getReadAdapter()->quoteInto('t1.list_id = "?"',123); $select = $this->_getReadAdapter()->select()->from(array('t1'=>$table))->join(array('t2'=>$table2), $cond)->where($where); echo $select."<br/>"; $select = $this->_getReadAdapter()->select()->from(array('t1'=>$table))->joinLeft(array('t2'=>$table2), $cond)->where($where); echo $select."<br/>"; $select = $this->_getReadAdapter()->select()->from(array('t1'=>$table))->joinRight(array('t2'=>$table2), $cond)->where($where); echo $select."<br/>"; echo $select."<br/>"; }This is the output I got in the my pc
SELECT `t1`.*, `t2`.* FROM `aws` AS `t1` INNER JOIN `customer_entity` AS `t2` ON t1.id = t2.customer_id WHERE (t1.list_id = "123") SELECT `t1`.*, `t2`.* FROM `aws` AS `t1` LEFT JOIN `customer_entity` AS `t2` ON t1.id = t2.customer_id WHERE (t1.list_id = "123") SELECT `t1`.*, `t2`.* FROM `aws` AS `t1` RIGHT JOIN `customer_entity` AS `t2` ON t1.id = t2.customer_id WHERE (t1.list_id = "123")
So, here you can see clearly how to use joins. I don’t think much explanation is required, the function call are self-explanatory. We can also use joinCross, joinFull, joinNatural as well, if you require it in any query. Please look at Varien_Db_Select class for details.
COUNT,MAX
Again, lets take another sample code
public function countUs(){ $table = $this->getMainTable(); $where = $this->_getReadAdapter()->quoteInto("id = ?", 123); $select = $this->_getReadAdapter()->select()->from($table)->reset('columns')->columns(new Zend_Db_Expr('count(*)')); echo $select.'<br>'; $select = $this->_getReadAdapter()->select()->from($table)->reset('columns')->columns(new Zend_Db_Expr('max(list_id)')); echo $select.'<br>'; }This is the output.
SELECT count(*) FROM `aws` SELECT max("list_id") FROM `aws`As you can see here, using Expr classes, we do mysql averaging functions.
query() function
In the end, if you have a very complex sql query, you want to execute you can simple use the query function.
$sql = ‘…complex sql…’;
$this->_getReadAdapter()->query($sql);
UPDATE, DELETE Querypublic function updateUs(){ $table = $this->getMainTable(); $where = $this->_getWriteAdapter()->quoteInto('id = ?', 1); $query = $this->_getWriteAdapter()->update($table, array('product_id'=>2,'file_id'=>3),$where); }Here you can see how to execute the update query.
UPDATE `aws` SET `product_id` = ?, `file_id` = ? WHERE (id = 1)
For delete query, it’s very simple
$this->_getWriteAdapter()->delete($table,$where)->limit(1);
Important Note: Its considered good practice in magento, to execute these sql query in the resource files only. You can get the read adaptor object in model, phtml or any other files and do the above operations in any file. But as good practices, always try to do the query in resource/mysql4 files only.
Exercise:Well, it would best if can try out all the queries mentioned above yourself, to get a hold on all the syntax. -
How to Set, Retrieve and Unset Session Variables in Magento
Use of session in Magento:
Let’s start this blog with the session definition, ‘It is a way to preserve certain data across subsequent accesses’. This enables you to build more customized applications and increase the appeal of your web site. Now, Let’s see how to set ,unset and retrieve a session in Magento.Generally, Magento session is handled by core Module ‘core/session’. We use “set<session name>” to set a session variable. For more understanding, look on to the following syntax and example.
Mage::getSingleton(‘core/session’)->set<YOUR SESSION NAME>(<VARIABLE NAME>);
Example :
$myValue =’test’;
Mage::getSingleton(‘core/session’)->setMyValue($myValue);In this example, I have declared the variable $myValue as “test”. I am going to set this variable in session. To do so, I have used the default syntax of the Magento in line 2. Now the session variable is set in the magento.Wow, its easy to set the session variable.
Let’s now look, how to get value from the session variable “MyValue”. To retrieve the session variable, we use
get<YOUR SESSION NAME>();
Mage::getSingleton(‘core/session’)->get<YOUR SESSION NAME>();
In our example, we need to get the session value of “MyValue”. For this, let’s use “getMyValue();”. So our code will be as follows,
$getSession =Mage::getSingleton(‘core/session’)->getMyValue();
Next, we will see how to unset the session variable. To unset the session variable, we have the following syntax,
Mage::getSingleton(‘core/session’)->uns<YOUR SESSION NAME>();
Let’s have a simple example to unset the session variable.
Mage::getSingleton(‘core/session’)->unsMyValue();
This code will automatically delete the session of the MyValue.How to Use customer or core session in frontend. Use adminhtml session in the backend.
Core Session :- Mage::getSingleton(‘core/session’)
Customer Session :- Mage::getSingleton(‘customer/session’)
Admin Session :- Mage::getSingleton(‘adminhtml/session’)
Shopping Cart Session :-Mage::getSingleton(‘checkout/session’)->getQuote() -
Solving out of memory errors with PHP and Composer on EC2s free tier
For one of my recent projects, I wanted to make use of the free allowance that AWS gives for SES.
One of the conditions of the SES allowance was that your calling app needs to be hosted on EC2.
I’ve not used EC2 before so I figured this would be a good way to dive into it.
Whilst I would never usually install software like a composer on a production server, this was pure to test things out.
So after signing up for AWS and creating a local ubuntu server on an EC2 t2micro instance then cloning down the project I ran composer install to come across the following message:
composer install Loading composer repositories with package information Updating dependencies (including require-dev) mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory PHP Fatal error: Out of memory (allocated 822091776) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223 Fatal error: Out of memory (allocated 822091776) (tried to allocate 4096 bytes) in phar:///usr/local/bin/composer/src/Composer/DependencyResolver/Solver.php on line 223822091776bytes is over 800mb of memory being consumed by the composer.
Whilst php-fpm has a 128mb max memory limit per script by default,
php-cli has a value of -1 which means use unlimited memory.In this instance attempting to allocate over 800mb of memory on a server with 1gb was not going to end well.
The solution was to create a swap file on the disk.
A swap file or partition is space on disk allocated that can be used when the physical memory allocation is exhausted. Once the allocation is exhausted, older items in memory get offloaded to the swap partition.
The actual solution for this I found over on this GitHub issue.
The following code will create a 1gb swap file in
/var/swap.1for our instance to usesudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 sudo /sbin/mkswap /var/swap.1 sudo /sbin/swapon /var/swap.1

