It allows frontend developer to send ajax requests and return a custom information from the server without a php developer help

Overview

VF_EasyAjax Module

Build Status Codacy Badge

Allows frontend developers send ajax requests for every page and get Json response.
You don't need to work with app/code section of Manento and change any PHP code.
Make all what you need works via Ajax using only layout xmls, theme templates and javascript.

In the Json response frontend developers can receive:

  • All messages that were added to session
  • Some blocks from current page layout
  • Any block that should be added to special layout xml

See the example of using Easy Ajax extension: Ajax Cart extension with only one JS file and without any PHP code.

What's new?

  • Added 'update' method to easy load and update container with data using mapping
  • Fixed compartability with prototype 1.6 (Magento < 1.6)
  • Fixed checking that module is enabled
  • Fixed compartability with Magento < 1.6
  • Added 'redirect' param with url where controller want to redirect
  • Fixed issue with custom layout when cache is enabled

How to install

You can either copy all files to magento root and install it using modman or composer

To install using composer make sure that you have firegento repository set

    "repositories": {
        "firegento": {
            "type": "composer",
            "url": "https://packages.firegento.com"
        }
    }

then add "hws47a/easy_ajax":"~1.1" package to the require part.

How to use:

For any page url add easy_ajax=1 and this page returns json instead of html.
It returns:

  1. messages: [{type: , code: }] if on this page some message is added to any session model.
  2. action_content_data: {} if you add to params action_content[] with block names
  3. custom_content_data: {} if you add to params custom_content[] with block names

Custom layout:

You can use additional layout handlers for easy ajax requests:

  • - blocks from it can be loaded from any easy ajax request
  • - you can specify a layout for each action. blocks from it can be loaded only from ROUTE_CONTROLLER_ACTION request.

Example

For add product to cart via Ajax use default add to cart url and add this params:

  • easy_ajax: 1
  • action_content[0]:cart_sidebar
  • action_content[1]:top.links

You will get json response with

  • messages: [{type: 'success', code: 'Massage that product was successfully added to cart.'}]
  • action_content_data: {cart_sidebar: "
    ", top.links: "
      "}

    So with response data you can simple update needed blocks:

    • cart_sidebar with items recently added to cart
    • top.links with count of items near link to My Cart

    Custom layout example

    Add to layout handler some block with name "test_default"
    Add to layout handler some block with name "test"
    Add to request 2 additional fields:

    • custom_content[0]: test_default
    • custom_content[1]: test

    You will get response with additional field:

    • custom_content_data: {test_default: "...", test: "..."}

    JS Wrapper for requests

    1. Using EasyAjax.Request instead of Ajax.Request you don't need to specify easy_ajax=1 param and you can add action_content and custom_content params easy. To add action_content and/or custom_content params just add it to options list as arrays.

    Example:

    new EasyAjax.Request(href, {
         method: 'post',
         action_content: ['cart_sidebar', 'top.links'],
         parameters: params,
         onComplete: function (transport) {
            //some code...
         }
     });
    

    2. Second useful method is EasyAjax.update. Use it if you want to easily load data and add it to some container.
    action_content will be used to load data.

    The code can look like this:

    EasyAjax.update(location.href, {
        "top.links": ".top-links-container",
        "block.card":".top-card-container"
    });
    

    RESTful requests

    Instead of using easy_ajax=1 in params you can use RESTful interface and .json to action name.
    Example: instead of customer/account/loginPost?easy_ajax=1 you can use customer/account/loginPost.json

    NOTE: This feature is disabled by default, to enable it just uncomment default/web/routers/json in config.xml

    Unit Tests

    Unit Tests writing is in progress.
    To run PHP tests use EcomDev_PHPUnit module.
    To run Js file test use CasperJs.

Comments
  • Added composer file

    Added composer file

    So we can install the module with http://packages.firegento.com/

    You'll need to edit yourvendorname and choosealicense (from this list). You can of course edit any other thing, those are just the required one :smile:

    opened by chadrien 2
  • Product Types Support

    Product Types Support

    This extension is brilliant! Would love to see support for product types.

    Layout xml containing product types are not processed i.e. <PRODUCT_TYPE_simple, <PRODUCT_TYPE_configurable, etc. in e.g. \app\design\frontend\rwd\default\layout\catalog.xml

    Hack Fix: Easy Ajax handles get added after the product type handles. So the update declared by the product type handles do not apply to the Easy Ajax handles. Extended the EasyAjax Response model and placed the handles before the type handles.

    Feature 
    opened by matthew-valenti 1
  • RESTful requests

    RESTful requests

    Improvement suggestion. At the moment to get JSON data from a server developer should use URL with the following structure:

    http://www.example.com/some/data?easy_ajax=1
    

    But I want to get data from a server using URL like this one:

    http://www.example.com/some/data.json
    
    Feature 
    opened by vsushkov 1
  • Messages which are displayed by Easy Ajax are also added to the session

    Messages which are displayed by Easy Ajax are also added to the session

    I'm using Ajax Cart with Magento 1.7.0.2. When I add a product to the cart, the success message is displayed. But when I reload the page, the message is also displayed (from the session).

    So messages are added as Easy Ajax message and as Session message.

    Bug 
    opened by iamniels 0
  • Fixed module name in isModuleEnabled calls

    Fixed module name in isModuleEnabled calls

    Without this change it doesn't push messages to array, because module name is different.

    I'm Magento noob, so maybe I'm making something stupid, so please check :)

    opened by dimsemenov 0
  • Problem with disabling module

    Problem with disabling module

    if module turn off from VF_EasyAjax.xml :

    <config>
        <modules>
            <VF_EasyAjax>
                <active>false</active>
                <codePool>local</codePool>
            </VF_EasyAjax>
        </modules>
    </config>
    

    Magento will be crashed when call method add() from Mage_Core_Model_Message_Collection

    opened by sergoslav 0
  • Messages being added to session storage

    Messages being added to session storage

    In VF_EasyAjax_Model_Core_Message, after a message is added to VF_EasyAjax_Model_Message_Storage, it is passed to its parent::_factory function where it proceeds to be added to session storage as well. As a result, subsequent pages that implement a Mage_Core_Block_Messages block display session messages. Ideally messages created during an Ajax request should not get stored in the session at all as the affect is that they are displayed a page late.

    For example, when using EasyAjax to add an item to the cart, a message "Product was added to your shopping cart." is created and added to session storage. When the user refreshes or navigates to a different page the flash message stored during the Ajax request is rendered by the Mage_Core_Block_Messages block. At this point the message is a page late and should have already been handled by Javascript upon completion of the Ajax request.

    opened by brizzo 3
Owner
Vladimir Fishchenko
Product Engineer @ Wayflyer. Have been Magento Developer for 10+ years. Magento Community Maintainer
Vladimir Fishchenko
Miniset allows you to create compact sets of fields that either combine into a string of classes, or return a simple array of values

Miniset allows you to create compact sets of fields that either combine into a string of classes, or return a simple array of values. Miniset

Jack Sleight 5 Jun 13, 2022
Silverstripe-searchable - Adds to the default Silverstripe search by adding a custom results controller and allowing properly adding custom data objects and custom fields for searching

SilverStripe Searchable Module UPDATE - Full Text Search This module now uses Full Text Support for MySQL/MariaDB databases in version 3.* Adds more c

ilateral 13 Apr 14, 2022
Add scalar type hints and return types to existing PHP projects using PHPDoc annotations

PHPDoc to Type Hint Archived! This repository is now archived. Consider using PHP CS Fixer (and especially the phpdoc_to_param_type and phpdoc_to_retu

Kévin Dunglas 228 May 22, 2022
CRUD Build a system to insert student name information, grade the class name, and edit and delete this information

CRUD Build a system to insert student name information, grade the class name, and edit and delete this information

Sajjad 2 Aug 14, 2022
EXT:server-timing adds Server-Timing Header with usefull information

EXT:server_timing - see your performance installation composer require kanti/server-timing at the moment there is nothing to configure Server timings

Matthias Vogel 4 Oct 26, 2022
Here is an Instagram Guest API. Gather all public information as JSON format without logging yourself.

Here is an Instagram Guest API. Gather all public information as JSON format without logging yourself. It's all automation and time saving.

Quatrecentquatre 1 Nov 2, 2021
Magento 2 Megamenu extension is an indispensable component, and plays the role of website navigation to help customers easily categorize and find information

Mageno 2 Mega Menu (Magicmenu) helps you create neat and smart navigation menus to display the main categories on your website.

https://magepow.com 35 Dec 1, 2022
salah eddine bendyab 18 Aug 17, 2021
Ask your friends to send you an anonymous message without knowing them

Ask your friends to send you an anonymous message without knowing them. ????????

Siavash 1 Apr 16, 2022
This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker.

Enqueue 35 Nov 4, 2022
A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

Google APIs 58 Dec 23, 2022
Glz custom fields - Unlimited Custom Fields for Textpattern

Unlimited custom fields for Textpattern This plugin sits under the Extensions tab in the back-end and gives your custom fields new life. You can final

Gerhard Lazu 21 Dec 1, 2019
Magento 2 custom extension to add custom attributes(longitude, latitude) to customer address

Magento 2 custom extension to add custom attributes(longitude, latitude) to customer address. Then save them to quote model and copy them from quote address to order address on bakend, frontend, rest api

MageArab 2 Jul 14, 2022
A plugin that allows you to hear the sound "Welcome to the server!" when you join the server by NhanAZ for PocketMine-MP

General A plugin that allows you to hear the sound "Welcome to the server!" when you join the server by NhanAZ for PocketMine-MP Contacts You can cont

NhanAZ's PocketMine-MP Plugins 10 Sep 27, 2022
A playable minesweeper developed with HTML, AJAX, PHP and BladeOne technology

minesweeper Escribe una aplicación PHP que lleve a cabo la siguiente funcionalidad: Se trata de implementar un sencillo juego de buscaminas. El Buscam

ManuMT 1 Jan 21, 2022
A playable tic-tac-toe game developed with HTML, AJAX, PHP and BladeOne technology

tic-tac-toe Escribe un programa PHP que implemente el juego del tres en raya. La aplicación creará una cuadrícula en la que el jugador podrá introduci

ManuMT 1 Jan 21, 2022
Simple Form By Using ⇒ PHP - MSQL - AJAX

php-form Simple Form By Using PHP - MYSQL - AJAX Demo: http://php-form.ga/ How To Use Download XAMPP from https://www.apachefriends.org/download.html

Areeb Ghani 1 Oct 23, 2021
Simple Form By Using ⇒ PHP - MSQL - AJAX

php-form-2 Simple Form By Using PHP - MYSQL - AJAX Demo: http://php-form.ga/ How To Use Download XAMPP from https://www.apachefriends.org/download.htm

Areeb Ghani 1 Oct 24, 2021