GSoC’17 Coding period | Week #6 | UC-Wishlist

week6

 

With the conclusion of the sixth week of Google Summer of Code 2017, the Coding regime is nearly halfway through the second phase. The previous week involved some basic albeit important conceptualizations, which have been of immense help and have provided noteworthy assistance for understanding the port functionality.

As mentioned earlier, the previous week I had summarised the implementation for the third port concerning the second phase, i.e, porting ‘View/Update wishlist’ functionality. Concerning the above port the following tasks had to be considered:

  • Creating the WishlistViewForm class by implementing the​ Form &​ Module API​ s, where the forms are created using ​  $form=\Drupal::formBuilder()->getForm( )​.

  • Providing an interface defining a wish list entity by creating the class UcWishlistInterface by extending ContentEntityInterface and EntityOwnerInterface.

  • The callback: uc_wishlist_display($wid, $mode) is utilised under the function uc_wishlist_view_form to check for required permissions and private checkbox for lists:

    • Set $wid (wish list id) if it is null.
    • Check the if user is wish list owner and provide right to edit.
    • If the user is not the owner and there are no products, then show the link to search. 
    • Display the required list if user is the owner or list is not private.
  • Creating the UcWishlist.php file in order to define user entity class.

As of now, I’ve completed a significant portion of porting the the first functionality, i.e., ‘Viewing/Updating user wish list’. Moreover, the ‘Update’ functionality is integrated through the WishlistViewForm config form/class to modify any specific wish list, so that on accessing the ‘Wish list’ link the user wish list is displayed with the added products and gets the products post data and iterate them to update one by one in a specific wish list and update the information for this product in the wish list.

Regarding the fourth port, i.e., porting ‘Search Wishlist’ functionality, based on a comprehensive analysis of the same, the following work had been done the earlier week:

  • Learnt implementation of Search API for executing a functional and effective search:

    • Search submit button: To execute the required search.

    • Search results list: Displaying the expected search results.

    • Search text box (textbox): If there are keywords, check for the user, wish list title, or address matches.

  • The usage of the Database API would involve the following :

    • $db = \Drupal::database()​: Gets the connection object for the specified database key and target.

    • $data=$db→select('uc_wishlist','wid')→fields('wid')→execute()​: Checks if wish list is not private.

    • $query->condition(db_or()

                   ->condition('u.name','%'.$keywords.'%','LIKE')

                   ->condition('w.title','%'.$keywords.'%','LIKE')

                   ->condition('w.address','%'.$keywords.'%',

                   'LIKE'))​​ :

                   makes three queries and returns a new DatabaseCondition.

search

The code for the current status of the port can be found here.

Winding up, these were the objectives and concepts learned during the third week of coding phase in GSoC’17. Hope to learn many more new concepts in the coming weeks for the successful completion of the port.

Cheers!